Vim Tips
Posted on 2013-12-06 20:08:11 +0900 in Technology
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 exampley`a
yank from here to he markeda
-
use markers in the way
a z b e
-
"zyy
and"zp
copy to z register and paste fromz
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;
andg,
move (forward,backward) through the changelist -
gi
go to the last place you inserted a text -
Ctrl-o
andCtrl-i
to go to the previous/next location you jumped to -
fa
go to the nexta
in the line -
t,
go to before the next,
-
F
andT
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 ```