| Share |
Updated: April 23rd, 2008
[WORK IN PROGRESS] Here is a list of commands that I use every day with vim, in no particular order. Out of a billion possible key combinations, I found these to be irreplaceable and simple enough to remember.
* | search for the word under cursor (to the end of the file) |
# | search for the word under cursor (to the top of the file) |
ctrl-p,ctrl-n | suggest (p)revious or (n)ext autocomplete from the list of existing keywords in the file or included files (!). |
:go NNN | go to byte NNN |
. | redo last command |
/SEARCH TERM | search document for SEARCH TERM |
:%s/FOO/BAR/gci | replace FOO with BAR (g)lobally, case (i)insensitively, and asking for (c)onfirmation |
n (N) | next (previous) search result |
% | find and jump to a matching brace or parenthesis |
u | undo |
ctrl-r | redo |
r CHAR | replace character under curson with CHAR |
i | start editing before current character |
I | start editing in the beginning of current line |
a | start editing after current character |
A | start editing at the end of current line |
o | start editing on the next line |
O | start editing on the previous line |
:wq or ZZ | write file and exit |
ctrl-v | visual block select (rectangular) |
shift-v | visual line select |
ctrl(or shift)-v y or d | copy or delete selected text |
yy | yank (copy) current line |
yNNN arrow up/down | yank NNN lines above or below |
p | paste the yanked buffer |
cw | change word (delete word under cursor and go into edit mode) |
cNw | change N words |
e! | reload the file (revert) |
Artem Russakovskii is a San Francisco programmer, blogger, and future millionaire (that last part is in the works). Follow Artem on Twitter (@ArtemR) or subscribe to the RSS feed.
In the meantime, if you found this article useful, feel free to buy me a cup of coffee below.
beer planet is a blog about technology, programming, computers, and geek life. It is run by Artem Russakovskii - a local San Francisco geek who currently works at
Nice sheet, I wrote a few of these down for myself. You're missing some good ones though:
When in visual select mode:
x to "cut" instead of Yank
> to "tab" the visual block
< to "untab" the visual block
D to delete characters on the line after the cursor
dd to delete the line
(N)dd to delete N number of lines (10dd to delete 10 lines)
G to end of file
:q! exit without saving
Thanks, Ikai. Yeah, this sheet is a work in progress, it's definitely not finished. I'm using this post as a scratchpad and will be adding more useful commands as time permits.
very cool !!!
I didn't realize anyone used VI any more except those of us developing Unix code.
Good Stuff !!!!
Oh yeah, most definitely. I love vim, and it gets more and more natural and easy to use every day.