vim Advanced Techniques

copy and paste

  • After the normal mode or v y / d / x replication, p to paste

    Edit mode

  • The default set autoindent will lead to paste the code can lead to confusion indent
  • One can turn off the autoindent, two can set the mode set paste into paste, paste after their recovery

Select register, the register system used

  • Using the "register select, for example," add to the current line can be saved in a register, if the register is not specified, the default will be saved to the unnamed register
  • Used "+to select the system register, in this case, may be attached in different places. Of course, the same may be other places where copies, and then in vim "+pto paste
  • Before using the system register, to execute the command : echo has('clipboard')if the system can use the output of register 1

Completion

  • ctrl + n to match completion, and using ctrl + n and ctrl + b complement selection switches

Macros

  1. In normal mode, according to q, and, for example, followed by a selection register will register a macro to save the recording, into the recording mode, and all operations will be recorded, including normal and insert mode, press the q in the normal mode end recording
  2. In normal mode, select @a, the macro can be played back, except mormal mode command may also be performed in virsual modes: first enters v mode, select the place to be treated, and then press the :enter command mode, enter normal @athe transport

Mobile modification command

  1. Under normal mode, w / W, b / B movement (W / B space as separator only recognize words), w between words to the beginning of a word, b to the end of a word
  2. Jump f + using the same line of characters, the character can jump to the beginning of the character as the press: to switch to the next match, the character represented by F + Reverse Search
  3. Under insert mode, you can use ctrl + w to delete forward one word, ctrl + h to delete a character, ctrl + u delete an entire row
  4. In the normal mode, press r / c / s to the current cursor word replace, change, immediately after the operation mode enters substitu the insert, may be used in the normal mode by CW, it indicates the current character deleted, re-enter
  5. zz can move the cursor to the middle of the screen content
  6. dt) delete to) to delete the right parenthesis
  7. d + digital, digital characters to delete

Seek

  • Match a search word under the cursor, the next match *

Syntax Highlighting

  • sytax on
  • Magic =, in the visual mode, select all the press =may be aligned with the current code
  • gi back to the last edit location

to sum up

The best way to learn is to experience problems after query

Guess you like

Origin www.cnblogs.com/hustcpp/p/11332195.html