Pages

Friday, August 2, 2013

Vim cheatsheet

* - search word under cursor
:!time - execute shell command time
~ - change case of character under cursor
0 - goto start of line
$ - goto end of line
Ctrl+f - Page Down
Ctrl+b - Page up
e - forward one token
b - back one token
o - Add blank line after current cursor position and go to insert mode
O - Add blank line before current cursor position and go to insert mode
V1< or V3>: Indent a region
. - Repeat previous actions
df + key - Delete all characters in the line up till and including <key>
Shift+Delete - Delete all characters until end of line

When you don't know how many lines you wish to yank/cut use these commands:
mk - mark line
y'k - yank (copy)
d'k - cut

:e <filename> - open file for editing
:sp - split window horizontally
Ctrl+wv or :vs - split window vertically
Ctrl+ww - switch window
Ctrl+w = - Resize split windows to adjust to screen resolution
Ctrl+w r - Rotate windows in a row

Commenting multiple lines:
Ctrl+v to go into visual mode and select the lines you wish to comment. Pressing : will give you this prompt:
:'<,'> promt which you should extend to :'<,'>s/^/#/
Uncommenting lines:
Ctrl+v to go into visual mode and select the commented characters. Press x to delete them

http://vim.wikia.com/wiki/Cut/copy_and_paste_using_visual_selection
http://vim.wikia.com/wiki/Using_tab_pages

No comments:

Post a Comment