Vim Tips
Deletion
-
‘dw’ deletes the word including the space.
-
‘d$’ deletes from the cursor to the end of the line.
-
‘de’ deletes the word excluding the space.
-
‘d2w’, ‘d2e’ delete 2 words.
-
‘dd’ deletes a whole line, ‘2dd’ deletes 2 lines.
-
‘p’ puts the deleted content.
Navigation
-
‘0’ goes to the start of the line. ‘$’ goes to the end of the line.
-
‘2w’ goes 2 words ahead.
-
‘2e’ goes to the end of the second word ahead.
-
‘G’ goes to the bottom, <C-g> shows the location status, ‘gg’ goes to the top, ‘5G’ goes to the 5th line.
Modification
-
‘u’ undoes, ‘U’ fixes the whole line, <C-r> undoes the undo.
-
‘r’ and ‘a’ replace the char with a.
-
‘ce’ and ‘abc’ change the word to the end with abc.
-
‘c$’ changes to the end of the line.
-
:r foo appends the content of foo to the file.
-
‘R’ goes to replace mode.
-
‘y’ yanks and ‘p’ pastes, ‘yw’ yanks word.
-
‘gt’ goes to the next tab, ‘gT’ goes to the previous tab.
-
:1,10s/foo/bar/g
replaces foo with bar between line 1 and line 10.
Miscellaneous
-
To enable spell check :setlocal spell spelllang=en_us .
-
:terminal to open terminal, <C-\><C-n> to enter vim mode to enable go up and go down.
-
g, <C-g> to see the word count.
Plugins
Multiple Cursors
In normal mode, <C-n><C-n><C-n>c, new_name (select 3 variables and rename.)
Emmet
html:5_
("_" is the cursor position), then <C-y> , , we get:
|
|
Tagbar
F8 to toggle.
NERDTree
:NERDTreeFocus to turn on.