Summary commonly used vim command, so that you learn these eighty

Walking under Linux heroes estimated that no one does not know vim, but many people may simply use it, or use it every time check the Internet. But seriously think about, it seems that many commands not immediately know how to use. Today, this number of categories for everyone here summed up some of the shortcuts and techniques of VIM, we want to help.

Summary commonly used vim command, so that you learn these eighty

edit

  • The command can repeat last modified. Various operations in the normal mode a modified operator (not including jumps and cursor movement), edits in the edit mode can be considered a modification. (Can be used. The numbers do not directly)
  • caw delete the current word and enter insert mode. c3w delete three words. c it means to delete the text and enter the edit mode. (This command with the following look down / {char} or *, easily through. Batch alternative words) to delete the cursor C after all, and insert mode.
  • dw Delete (including the cursor) after the current cursor, daw delete an entire word. (W, b respectively represent itself to the next word and the previous word). D delete all the words after the cursor (including the cursor) current. dd delete the entire line.
  • y replication, and d is substantially the same
  • d + i] represents the current cursor position is deleted in the contents of [] matches, if it is a] so be removed even with the brackets. There are similar c, y represents insert and remove and copy. i] may be i), i} and the like corresponding to the command. (Aw above daw wherein it here and similar, as well as the corresponding DIW). (A command is useful cool)
  • p Paste. Divided into two cases:
  • If the copy is a full-line attached at p represents the current line, P pasted on the current line.
  • If the copied several words are attached p represents the current cursor, P is attached before the cursor.
  • o insert a row at the current row and editing, O insert a row in the current row and edit
  • x delete the letter under the cursor, i inserted after the cursor, a cursor inserted before, A is inserted into the end of the line, I is inserted into the first line.

search for

  • / {Char} down command for a match. There are similar * to match the current word under the cursor. At the next n, N on a. Find text can be transferred into a highlight, if not through: (hightlight search of the meaning) setting set hls, canceled with: set nohls can be.
  • If you want to cancel the search type: noh (nohighlight) can be.
  • Vim default is case sensitive, you can: set ic (ignore case meaning) cancel case sensitive, you can also re-use: set smartcase when a letter is capitalized startup case sensitive
  • In selected cases, type: '<,'> s / foo / bar / g shows a foo replace bar. When filled with vim default '<,>', so long as the input s / foo / bar / g to: the type selection conditions. / G denotes replace all, s represents selected

Jump

  • zz will appear in the window the middle of the current line. For example, the code you read, read, I wrote about the bottom of the screen, this time do not need to scroll up, use the shortcut on the current line can be moved to the middle of the window, continue editing.
  • gg Go to the top of the page (plus import files very good use of the time). G Skip to the bottom (when applied with the method).
  • w, b skip to the next / previous word (consecutive symbols can be considered a word). W, B ignore symbol, a space as a dividing line.
  • e (end) to quickly jump to the end of the word the cursor. And w, b with use. (Also very good use, w and b can jump forward and backward with the word, but the cursor is in front of the word. E may be used to the end of a word, the word can be input by a later). E is similar to W, B to space as a dividing line, jump to the word of the tail.
  • mx marker X (X Mark), `X adjusted labeled x. This is also very easy to use, for example, you want to add a reference in the file header, then the first mark at the current line.
  • % Can start in a group, the Bi jumps in parentheses. If the current cursor position is not a parenthesis, then jump to the nearest post a parenthesis at the current cursor. Write oc when this method is useful ah.
  • CTRL + E screen scrolls down one line, CTRL + Y screen is scrolled up one line. CTRL + D and CTRL + U was originally a half-screen scrolling, we can map in your .vimrc five lines:
1
2
3
".vimrc
map <C-U> 5<C-Y>
map <C-D> 5<C-E>

select

Mainly used to copy and delete

  • v enter selection mode. Speaking of all of the above may be blended: w, b, i], 3w
  • V select an entire row.

This concludes command often used in everyday use, but vim is too strong, if all presentation may need to write a book. Below is a summary view of other cattle people, you can print out control exercises.

Summary commonly used vim command, so that you learn these eighty

This number've got some high-definition version of vim operating diagram, can be obtained by the following way. This number that can be dedicated to practice for some time, have to practice against, you can consider every twenty-three days to practice for an hour, continued to practice a month. In this way, to have mastered a system of vim, or it may have been in use only a few simple commands the stage.

Focus on micro letter:  itworld123 , private letter reads: vim

Guess you like

Origin blog.csdn.net/shuningzhang/article/details/90579746