V | select entire line |
v | select range of text |
ctrl + v | select columns |
gv | reselect block |
/ pattern | search for pattern forwards |
? pattern | search for pattern backwards |
n | repeat forward search |
N | repeat backward |
:set ignorecase | case insensitive |
:set smartcase | use case if any caps used |
:set incsearch | show match as search proceeds |
:set hlsearch | search highlighting |
* | search for word currently under cursor |
g* | search for partial word under cursor (repeat with n) |
ctrl + o, ctrl + i | go through jump locations |
[I | show lines with matching word under cursor |
Use markers to set places you want to quickly get back to, or to specify a block of text you want to copy or cut
m a-z | mark current position (use a-z) |
' a-z | move to mark a-z |
d ' a-z | delete from current pos to mark a-z |
' a-z | same file |
' A-Z | between files |
:e filename | open filename in current window |
:split filename | split window horizontally and edit another file |
:vsplit file | split window vertically and edit another file |
:sview filename | same as split, but open file readonly |
:hide, ctrl + w c | close current window |
:only | keep only the current window open |
:ls | show current buffers |
:b 2 | open buffer #2 in current window |
ctrl + w n | split window horizontally |
ctrl + w v | split window vertically |
ctrl + w w | move cursor to the next window (cycle) |
ctrl + w arrow-up | move cursor up a window |
ctrl + w _ | maximizie current window |
ctrl + w = | make all windows equal size |
10 ctrl + w + | increase window size by 10 lines |
10 ctrl + w - | decrease window size by 10 lines |
ctrl + w c | close current window |
When you copy and cut stuff, it gets saved to registers. You can pull stuff from those registers at a later time.
:reg | show named registers and what's inside |
"5p | paste content of register "5 |
q a-z | record macro and save it in register a-z (use q again to stop recording) |
@ a-z | execute macro stored in a-z |
@@ | repeat las executed macro |
5 @@ | repeat it 5 times |
" a-z p | print macro a-z (e.g. to edit or add it to |
" a-z d | replace register a-z with what the cursor is on |
ctrl + t, ctrl + d | (insert mode): indent current line forward/backward |
visual > or < | indent block by sw (repeat with .) |
:set tabstop=8 | tabs are at proper location |
:set expandtab | don't use actual tab character (ctrl-v) |
:set shiftwidth=4 | indenting is 4 spaces |
:set autoindent | turns it on |
:set smartindent | does the right thing (mostly) |
:set cindent | stricter rules for C programs |
To stop indenting when pasting text with the mouse, add this to your
then hit F11 key while in insert mode (or just set
V = | select text, then reformat it |
= | will correct alignment of code |
= = | one line |
gq | reformat paragraph |
:set wrapmargin | |
:set textwidth | |
:set formatoptions | (default "tcq") t - textwidth c - comments (plus header -- see :help comments) q - allow 'gq' to work n - numbered lists 2 - keep 2nd line indent 1 - single letter words on next line r - (in mail) comment leader after |
ctrl + n, ctrl + p | next / previous word completion (similar word in current file) |
ctrl + x, ctrl + l (ctrl + n / ctrl + p) | line completion |
You can take the output of any command and send it into a vim session. From there you could format it, change stuff, and then save it to a file.