I watched a really good talk on Vim. It taught me a couple of
goodies that I didn’t know since before.
If you want to watch it, you can find it here:
https://www.youtube.com/watch?v=E-ZbrtoSuzw
Here are my notes from the talk.
Operators
Operators act on text objects or motions.
[count][operator][text object/motion]
| keystroke |
description |
| c |
change |
| d |
delete |
| y |
yank |
| ~ |
swap case (also u/U) |
| ! |
filter to external program |
| < |
shift left |
| > |
shift right |
| = |
indent |
Text objects
| keystroke |
description |
| aw |
a word |
| iw |
inner word |
| aw |
a WORD |
| iw |
inner WORD |
| ap |
a paragraph |
| ab |
a bracket |
| ib |
inner bracket |
| at |
a tag block |
| it |
inner tag block |
Motions
| keystroke |
description |
| % |
go to first matching paren/bracket |
| [count]+ |
down to first non-blank char of line |
| [count]$ |
to end of line |
| [count]f/F{char} |
to next occurence of {char} |
| [count]t/T{char} |
to before next occurence of {char} |
| [count]h/j/k/l |
left, down, up or right |
| [count]]m |
Go to beginning of next method |
| [count]w/W |
forward to beginning of word/WORD |
| [count]b/B |
backward a word/WORD |
| [count]e/E |
forward to end of word/WORD |
Navigation
| keystroke |
description |
| H |
High of screen |
| M |
Middle of screen |
| L |
Low of screen |
| zt |
Move screen so that cursor is in top |
| zz |
Move screen so that cursor is in middle |
| zb |
Move screen so that cursor is in bottom |
| ctrl-y |
Shift text down one line |
| ctrl-e |
Shift text up one line |
| ctrl-b |
Page up |
| ctrl-f |
Page down |
| ctrl-u |
Page half up |
| ctrl-d |
Page half down |
| gd |
goto definition |
| gf |
goto file (for instance when cursor is at a path) |
Marks
Works like bookmarks.
| keystroke |
description |
| m{a-zA-Z} |
set a mark |
| `{mark} |
goto mark |
| :marks |
show all marks |
| `. |
goto last change |
Jumplist
| keystroke |
description |
| ctrl-o / ctrl-i |
cycle through :jump |
| g; /g, |
cycle through changes |
Buffers
| keystroke |
description |
| :bn |
goto next buffer |
| b {filename} |
goto buffer {filename} |
| bd |
delete current buffer |
| :buffers |
list buffers |
| :bufdo {cmd} |
execute {cmd} for all buffers |
| :n |
goto next file, base on arg list |
| :arga {filename} |
add {filename} to arg list |
| :argl {files} |
make a local arg copy via {files} |
| :args |
print out all arguments |
Windows
| keystroke |
description |
| ctrl-w s |
horizontal split |
| ctrl-w v |
vertical split |
| ctrl-w q |
close window |
| ctrl-w w |
alternate window |
| ctrl-w r |
rotate window |
| :windo {cmd} |
execute {cmd} for all windows |
Tabs
| keystroke |
description |
| gt |
goto next tab |
| gT |
goto prev tab |
| :tabc |
close tab |
| :tabe |
open tab |
| :tabo |
close all other tabs |