Vim Tips

Posted on 2013-12-06 20:08:11 +0900 in Technology Vim

Here is some useful Vim tips

Normal

  • V multiline copy

  • . duplicate last command

  • I insert at the begin

  • A Append to end

  • J Join two lines

  • > and < indent block(in visual mode)

  • CTRL + A or X increase or decrease the number

  • ~ toggle the casing of a letter/selection(upper-case/down-case)

  • !! execute last command

  • <start position><command><end position> for example y`a yank from here to he marked a

  • use markers in the way a z b e

  • "zyy and "zp copy to z register and paste from z register

  • set ft=? look up current file type.

Move

  • % go to the corresponding (),{},[]

  • mz `z Marker and go to the last position

  • '. Jump back to last edited line

  • g;and g, move (forward,backward) through the changelist

  • gi go to the last place you inserted a text

  • Ctrl-o and Ctrl-i to go to the previous/next location you jumped to

  • fa go to the next a in the line

  • t, go to before the next ,

  • F and T are backward

  • w go to the start of the next word

  • b/e go to the beginning/end of this word

  • W go to the start of the following WORD(space separated only)

  • B/E go to the beginning/end of this WORD

  • { } to move to the beginning/ending of the paragraph

  • zz move current line to the middle of the screen

  • zt move current line to the top of the screen

  • zt move current line to the bottom of the screen

  • Ctrl+e move screen up one line

  • Ctrl+y move screen down one line

Zone selection

<action>a<object> and <action>i<object>

Action can be any action, for example d, y, c(change), v(select in visual mode). The object can be: w a word, W a WORD, s a sentence, p a paragraph. But also, natural character such as ",',),],}

vi" will select foo.

va" will select “foo”

Editing

  • cc change the entire current line

  • r replace the current character

  • R Enter Insert mode, replacing characters rather than inserting

Macro recording

/bin/bash: :q: command not found

  • q[ key ] to start recording

  • q to stop recording

  • @[ key ] to use the macro ```

----------------------------------- 本文内容遵从CC版权协议转载请注明出自kamelzcs -----------------------------------
«  | 左宗棠题江苏无锡梅园 »

Hide Comments

comments powered by Disqus