http://www.viemu.com/a_vi_vim_graphical_cheat_sheet_tutorial.html http://vim.wikia.com/wiki/ http://stackoverflow.com/questions/1218390/what-is-your-most-productive-shortcut-with-vim/1220118#1220118 http://www.yolinux.com/TUTORIALS/LinuxTutorialAdvanced_vi.html
zt
zz
zb
'>aB' ("indent a Block")
:tabe file
gt
Esc == Ctrl+C == Ctrl+[
Alt+command
d: delete - dd or D: delete line
c: change
y: yank (copy)
v: visually select (V for line vs. character)
forget sudo when save? Try this :w !sudo tee % then type L
Modifiers are used before nouns to describe the way in which you're going to do something. Some examples:
i: inside
a: around / append
o: new line below / O: newline above
NUM: number (e.g.: 1, 2, 10)
t: searches for something and stops before it
f: searches for that thing and lands on it
/: find a string (literal or regex)
In English, nouns are objects you do something to. They are objects. With vim it's the same. Here are some vim nouns:
w: word
s: sentence
): sentence (another way of doing it)
p: paragraph
}: paragraph (another way of doing it)
t: tag (think HTML/XML)
b: block (think programming)
-
Delete two words d2w
-
Change inside sentence (delete the current one and enter insert mode) cis
-
Yank inside paragraph (copy the paragraph you're in) yip
-
Change to open bracket (change the text from where you are to the next open bracket) ct<
Motion command reference
j: move down one line // line
k: move up one line //line
h: move left one character //char
l: move right one character //char
0: move to the beginning of the line //line
$: move to the end of the line //line
w: move forward one word // word
b: move back one word // word
e: move to the end of your word // word
): move forward one sentence //sentence
}: move forward one paragraph //paragraph
:line_number: move to a given line number
H: move to the top of the screen //screen
M: move to the middle of the screen //screen
L: move to the bottom of the screen //screen
^E: scroll up one line
^Y: scroll down one line
gg: go to the top of the file // file
G: go to the bottom of the file //file
^U: move up half a page
^D: move down half a page
^F: move down a page
^B: move up a page
If you ever need to cut/copy/delete/paste lines without knowing the actual number of lines, here is what you should do.
In normal mode, go to the beginning of the section that you want to yank. Type mk to mark this spot as k. Go to the end of the section you want to yank using whatever movement commands you like. Type: y'k (, , k) To yank from the mark to the current location. You can paste those lines wherever you want with p Similarly, d'k will cut/delete the lines from the current location to the mark.