Remember VIM is all about combining commands. These are just the basics with a few combination examples.
Tutor - vimtutor from command line
- i - start insert mode at cursor
- I - insert at the beginning of the line
- a - append after the cursor
- A - append at the end of the line
- o - open (append) blank line below current line (no need to press return)
- O - open blank line above current line
- ea - append at end of word
- Esc - exit insert mode
- Ctrl-[ - escape
- S - delete line and go into insert mode
- xp - Swap current character with the next one
- df then the character you want to delete to (and it deletes that character)
- CTRL+w + direction : Changes the focused pane.
- u - undo
- CTRL+r - redo
- r - replace a single character (does not use insert mode)
- J - join line below to the current one
- dd - Delete the line (d2d deletes two lines, d3d deletes three lines, etc.)
- yy - yank (copy) a line
- 2yy - yank 2 lines
- "ayy - this will store the line in buffer a
- "ap - this will put the contents of buffer a at the cursor.
- "a5yy - this will store the 5 lines in buffer a
- H : To the first line of the screen.
- M : To the middle line of the screen.
- L : To the the last line of the screen.
- 42G : Goto Line 42
- 42gg: Goto Line 42
- :42 : Goto Line 42
- CTRL+d : Goes down half a page
- ^ - first non-blank character of line
- $ - last character of a line
- G - End of File
ctrl + v - Visual block mode
- /pattern - search for pattern
- ?pattern - search backward for pattern
- n - repeat search in same direction
- N - repeat search in opposite direction
- :%s/old/new/g - replace all old with new throughout file
- :%s/old/new/gc - replace all old with new throughout file with confirmations
- :%s/foo/bar/gc
- :%s/foo/bar/gc
- :5,20s/foo/bar/ - replace line 5 to 20 foo with bar
- :./foo/bar/ - replace current line
- :.,+100s/foo/bar/ - replace next 100 lines from current
colorscheme ir_black #change colorscheme
##Window Ctrl + W #Intro window mode Ctrl + W then h,j,k, or l to choose what direction window to change focus too Ctrl + W then Shift + h, j, k, or l to move the window to that side of the screen.
s # When over the file use s to open it in a vertically split pane.
http://www.tuxfiles.org/linuxhelp/vimcheat.html