Vim command plot

Source: Internet
Author: User
Tags function definition function prototype save file


Ubuntu vim to install it
Installation and basic usage
  1. Log in to Ubuntu with root account, enter vim in the command line, if not installed, you will get the following prompt:
  The program "vim" is included in the following packages:
  * Vim
  * Vim-gnome
  * Vim-tiny
  * Vim-gtk
  * Vim-nox
    please try:
    code show as below:
  Apt-get install <selected packages>
  Follow the prompts to enter
    code show as below:
  Apt-get install vim
  Installation.
  2. After the installation is complete, enter vim to enter the standard mode of vim. At this time, press i on the keyboard to enter the insert mode.
  3. Press Esc to launch the insert mode and enter the standard mode. There are several basic commands to master in this mode.
  : Wq save launch
  I enters insert mode
  X delete character of current cursor
  Dd delete the current line and save the current line to the clipboard
  P paste
  : Help View help for the command
  光标 Move the cursor up, down, left and right
  4. Enter: w filename to save the file to the current directory.
  5 :: q Exit the vim page.
  6. Enter vim filename next time to edit or view this file.
  Common plug-ins:
  1.ctags installation
  Ctags can build the index of the source tree, so that programmers can quickly locate functions, variables, macro definitions, etc. to view the prototype when programming
  The following is the download installation and configuration process of ctags under ubuntu:
  Download and install ctags, enter command in terminal
  Copy code
    code show as below:
  Sudo apt-get install ctags
  Build source index, for example, I often need to consult the Linux kernel code, and these codes are placed in the /home/hjw951/arm/linux-2.6.12 directory
  After entering the directory in the terminal, enter the command ctags -R *, you will find that there is an additional tags file, this is the index file
  注册 Register the path of the index file tags with vim, enter gedit / etc / vim / vimrc as root user in the terminal
  添加 Add a line at the end of the open file (of course, the specific path is based on your own situation)
  Set tags = / home / user / arm / linux-2.6.12 / tags
  Then close the terminal and reopen, you can use VIM to view the function prototype of Linux anywhere
  2.taglist plugin
  Anyone who has used Source Insight remembers such a function: SI can display macros, global variables, functions, and other tags in the current file in the Symbol window. Click the tag with the mouse to jump to the position defined by the tag; you can press The alphabetical order, the class or scope to which the tag belongs, and the position where the tag appears in the file are sorted; if you switch to another file, the Symbol window updates to display the tags in this file.
  的 The taglist plugin in vim implements the similar functions described above, some of which are weaker than SI and some are stronger than SI. Moreover, the taglist plugin is still being improved!
  To use the taglist plugin, you must meet:
  Turn on the automatic file type detection function of vim: filetype on
  ExExuberant ctags tool is installed in the system, and the taglist plugin can find this tool (because taglist needs to call it to generate tag files)
  Your vim supports system () calls
  3.taglist installation
  (1) Create .vim in user home directory
    code show as below:
  [[Email protected] ~] $ mkdir .vim
  (2) Unzip taglist_45.zip to .vim directory
    code show as below:
  [[Email protected] ~] $ unzip taglist_45.zip -d .vim
  The directory structure after decompression is as follows
    code show as below:
  [[Email protected] ~] $ ls -R taglist
  Taglist:
  Doc plugin
  Taglist / doc:
  Taglist.txt
  Taglist / plugin:
  Taglist.vim
  (3) Install taglist
  [/ Code]
  [[Email protected] atom] # cp /taglist/doc/taglist.txt / usr / share / vim / vim71 / doc /
  [[Email protected] atom] # cp /taglist/plugin/taglist.vim / usr / share / vim / vim71 / plugin / [/ code]
  (4) Generate help tags
  Enter the doc path of vim.
    code show as below:
  Cd / usr / share / vim / vim71 / doc
  Start vim, enter in command mode
  : Helptags. (. Indispensable, it means the current directory. You can also start vim in any directory, just specify: helptags usr / share / vim / vim71 / doc /)
  After generating the help tags, you can use the following command to view the taglist help
  : Help taglist.txt
  You can now try to open the taglist in vim and enter the command
  : TlistToggle to open and close the taglist window. (Command can be abbreviated as Tlist)
  Command introduction
  Ctrl +]: jump to the function definition where the function is called
  Ctrl + t: Return to the previous search place.The directory structure after decompression is as follows

vim command, vim is a very good editing tool, the following introduces the basic commands for getting started with vim. 
Method/Step
  1. 1

    "Vim command-Start vimtutor": Execute command: Vimtutor. Vimtutor is an introductory tutorial on VIM usage. You can get started in 25-30 minutes.

  2. 2

    "VIM command-Move cursor":

    The key of H is on the left side and moves to the left each time it is pressed.

    The keys on the L are on the right, and each time you press it, you move to the right.

    The J key looks like an arrow pointing down in the tip direction.

    K move upwards.

  3. 3

    "Vim command-Start and exit":

    1. Press <ESC> (this is to ensure you are in normal mode).

    2.:q! < return car > do not save exit.

    3.:wq < return car > Save and exit.

  4. 4

    "Vim Command-edit delete":

    1. Press X to remove the character at the location of the light target.

  5. 5

    "Vim command-Edit Insert":

    1. Press I to insert the text.

  6. 6

    "Vim Command-Summary 1":

    1. The cursor movement in the screen text can be either arrow-key or HJKL-letter-Keys.

    H (Shift left) J (downlink) K (upstream) L (shift right)


    2. To enter the Vim editor (from the command line prompt), enter the:vim file name < return car >


    3. To exit the VIM editor, please enter the following command to discard all changes:


    <ESC>: q! < return car >


    or enter the following command to save all changes:


    <ESC>: Wq < return car >


    4. In normal mode, delete the character of the light target, press:x


    5. In normal mode, to start inserting text at the location where the light is located, press:


    I input necessary text <ESC>

  7. 7

    "Vim command-delete class command":

    1. The input DW can be deleted from the light to the end of a single word/phrase.

  8. 8

    "Vim command-Other delete command":

    1. Enter the d$ from the previous light to delete to the end of the line.

  9. 9

    "Vim command-about commands and objects":

    The format of the delete command D is as follows:


    [NUMBER] D object or D [number] Object


    The meaning is as follows:

    Number-Represents the number of times the command was executed (optional, default setting is 1).

    D-Represents the delete.

    Object-Represents the image to be manipulated by the command (the following is an introduction).


    A short list of icons:

    W-from the former position of the previous light until the end of the word/phrase, including spaces.

    E-from the former position of the previous light until the end of the word/phrase, but * does not include spaces.

    $-from the former position of the previous light until the end of the line.

  10. 10

    "Vim command-Special object for Object command":

    1. Enter DD to remove the entire current.

  11. 11

    "Vim command-undo command":

    1. Enter u to undo the last command and enter U to fix the entire line.

  12. 12

    "Vim Command-Summary 2":

    1. To delete to the end of the word/phrase from the previous light, enter:DW


    2. To delete from the current light to the end of the current line, please enter:d$


    3. To delete the entire line, please enter:DD


    4. The format of a command in normal mode is:


    [NUMBER] Command object or command [number] Object

    The meaning is:

    Number-Represents the number of times the command is executed

    Command-represents what to do, such as D for delete

    Object-Represents the image to be manipulated, such as W for a single word/phrase, $ for the end of the line, and so on.

    $ (to the end of line), etc.


    5. To undo the previous operation, please enter the:u (small write u)

    To undo the changes made in a row, enter:u (Big U)

    To undo the previous Undo command, restore the previous operation results, please enter:CTRL-R

  13. 13

    "Vim command-place Class meter command":

    1. Enter p after the last erased content is placed in the light target.

  14. 14

    "Vim command-replace Class command":

    1. Enter the characters of R and the position of a character to replace the light target.

  15. 15

    "Vim command-Change Class command":

    1. To change the part or all of a single word/phrase, enter the CW.

  16. 16

    "VIM command-C directive":

    1. Changing the type of instruction works in the same way as removing the command. The Operation format is:


    [number] C object or C [number] Object


    2. The same as the parameters, such as W for the single word/phrase, $ for the end of the line and so on.


    3. Please move the light to the first line in this section labeled--->.


    4. Then move the light target to the first bug.


    5. Then input C $ causes the remainder of the line to be corrected as in the second line. At the end, press <ESC>.

  17. 17

    "Vim Command-Summary 3":

    1. To reset the contents of the text that has been deleted, enter the small write letter p. This action can remove the

    Text content is placed after the light target. If the last delete is an entire line, then the row will be

    The next line in the row where the previous light is located.


    2. To replace the characters in the location of the light, enter the small write r and the new word to replace the original position character.

    Characters.


    3. Changing the command allows you to change the specified image from the position of the previous light target to the end of the image.

    For example, the input CW can be used to replace the previous light to the end of the word content, input C $ can be replaced

    The front light targets the content at the end of the line.


    4. The format of the Change Type command is:


    [number] C object or C [number] Object

  18. 18

    "Vim command-positioning":

    1.

    The input ctrl-g shows the line position of the previous light and the file status information in the previous edit file.

    The input shift-g jumps directly to a specified line in the file.

  19. 19

    "Vim command-search":

    1. The input/and trailing strings can be used to find the string in the current file.

  20. 20

    "Vim command-match parentheses":

    1. Press% to find the matching parentheses),],}.

  21. 21st

    "Vim command-fix error":

    1. Input: s/old/new/g can replace old as new.

  22. 22

    "vim Command-Summary 4":

      1. The ctrl-g is used to display the location and file status information of the previous light target. Shift-g is used to jump the light target

          to the last line of the file. First, hit a line and then press SHIFT-G to move the light to the line

         .

     

      2. Enter/Then tighten a string to find the string in the file that you were editing.

          Enter a question? Then the string is followed by the search for the word "

         " in the file you were editing. After completing a search, press N to redo the last command, and you can look in the same direction

          Find the next string, or press Shift-n to look in the opposite direction for the string where it is located.

     

      3. If the previous position of the light is the parentheses (,), [,], {,}, press% to move the light to the matching

          parentheses.

     

      4. In one line, replace the string old with the new string, enter  :s/old/new

          Replace all strings in a line Old to new string, please enter  :s/old/new/g

          Replace all strings in two lines with old as new string, enter  :#, #s/old/new/g

          Replace all the strings in the file with the old as new string, enter  :%s/old/new/g

          In the full text of the conversion, the user is sure to add a C option for each replacement, please enter:%S/OLD/NEW/GC

  23. 23

    "Vim command-Execute external command":

    1. Enter:! And then you enter an external command to execute the external command.

  24. 24

    "Vim command-Save file":

    1. To save the file to a file, please enter: w FILENAME

  25. 25

    "Vim command-selective save":

    1. To save part of the file, please enter: #,# w FILENAME

  26. "Vim command-Extract merged files":

    1. To insert additional file contents into the current file, enter: R FILENAME.

  27. "Vim Command-Summary 5":

    1.:!command is used to perform an external command.


    Please see some examples:

    :!dir-Used to display the contents of the previous catalogue.

    :!RM filename-the file used to delete the filename.


    2.: w FILENAME saves the files being editable in the previous VIM to the filename

    In the file.


    3.: #, #w FILENAME to save the contents of the previous edit file # line to # line to a file

    In FILENAME.


    4.: r filename Extracts the magnetic disc file filename and inserts it into the light target position of the current file

    Back side

  28. "Vim command-Open Class command":

    1. Enter o to open a new line below the light target and enter into insert mode.

  29. "VIM command-cursor insertion":

    1. Enter a will be able to insert text after the light target.

  30. "Vim command-permutation":

    1. Enter the big write R to replace multiple characters.

  31.  

    Vim command-options:

    1. To find the word ignore you can enter/ignore in normal mode. To re-find the verb, you can

          redo by pressing N.

     

      2. Then set the IC option (IC is English ignoring the initials of the Ignore case), i.e.

          Input:

    : Sets IC

     

      3. Now you can pass the key into the N key to find the word ignore again. The redo lookup can be re-key into the N keys.

     

      4. Then set the options for Hlsearch and Incsearch, and enter the following contents:

         :set HLS is

     

      5. Now you can enter the find command again to see what effect it will have:

         /ignore

  32. "Vim Command-Summary 6":

    1. Enter the small write o can open a new line under the light target and place the light in the beginning of the new

    Insert mode.

    Enter the big write O to open a new line above the light target and place the light at the beginning of the new start, enter

    Insert mode.


    2. Enter a small version of a can insert text after the light target position.

    A large write can insert text after the end of the line in which the light is placed.


    3. Enter the big write R to enter the swap mode until you press <ESC> to exit the swap mode and enter the normal

    Mode.


    4. Input: Set XXX can setup xxx option.

  33. "Vim command-online Help":

    Vim has a comprehensive in-line help system. To activate the Help system, please select the following three kinds of

    One of the methods:

    -Press <HELP> key (if any on the keyboard)

    -Press <F1> key (if any on the keyboard)

    -Input: Help < return car >


    Input: Q < return > can close the Help window.

  34. "Vim command-Create startup script":

    Vim has much more functional features than VI, but most features do not have a default activation. To activate more

    function, you have to create a VIMRC file.


    1. Start editing the VIMRC file, which depends on the operating system you are using:


    : Edit ~/.VIMRC This is the command used by the UNIX system

    : Edit $VIM/_VIMRC This is the command used by the Windows system


    2. Then import the VIMRC sample file:


    : Read $VIMRUNTIME/vimrc_example.vim


    3. Save the file with the command:


    : Write


Vim command plot


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.