Vim Tips
Posted on 2013-12-06 20:08:11 +0900 in Technology
Here is some useful Vim tips
Normal
-
Vmultiline copy -
.duplicate last command -
Iinsert at the begin -
AAppend to end -
JJoin two lines -
>and<indent block(in visual mode) -
CTRL + A or Xincrease or decrease the number -
~toggle the casing of a letter/selection(upper-case/down-case) -
!!execute last command -
<start position><command><end position>for exampley`ayank from here to he markeda -
use markers in the way
a z b e -
"zyyand"zpcopy to z register and paste fromzregister -
set ft=?look up current file type.
Move
-
%go to the corresponding(),{},[] -
mz `zMarker and go to the last position -
'.Jump back to last edited line -
g;andg,move (forward,backward) through the changelist -
gigo to the last place you inserted a text -
Ctrl-oandCtrl-ito go to the previous/next location you jumped to -
fago to the nextain the line -
t,go to before the next, -
FandTare backward -
wgo to the start of the next word -
b/ego to the beginning/end of this word -
Wgo to the start of the following WORD(space separated only) -
B/Ego to the beginning/end of this WORD -
{ }to move to the beginning/ending of the paragraph -
zzmove current line to the middle of the screen -
ztmove current line to the top of the screen -
ztmove current line to the bottom of the screen -
Ctrl+emove screen up one line -
Ctrl+ymove 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
-
ccchange the entire current line -
rreplace the current character -
REnter Insert mode, replacing characters rather than inserting
Macro recording
/bin/bash: :q: command not found
-
q[ key ]to start recording -
qto stop recording -
@[ key ]to use the macro ```