Vim¶
Opening¶
Open file: vi <filename>
Input Mode¶
| a | Append after cursor |
| i | Insert before cursor |
| o | Open line below |
| O | Open line above |
| :r file | Insert file after current line |
Leave input mode:<Esc>
Cursor¶
| H | Upper left corner (home) |
| M | Middle line |
| L | Lower left corner |
| h | Back a character |
| j | Down a line |
| k | Up a line |
| ^ | Beginning of line |
| $ | End of line |
| l | Forward a character |
| w | One word forward |
| b | Back one word |
| fc | Find c |
| ; | Repeat find (find next c) |
File Management¶
| :w | Write |
| :w <name> | Write buffer to name |
| :wq | Write and quit |
| :q! | Quit! |
| :sh | Invoke shell (<ctrl><d>) |
Search¶
| <ctrl>d | Scroll down (half a screen) |
| <ctrl>u | Scroll up (half a screen) |
| <ctrl>f | Page forward |
| <ctrl>b | Page backward |
| /string | Search forward |
| ?string | Search backward |
| <ctrl>l | Redraw screen |
| <ctrl>g | Display current line number and file information |
| n | Repeat search |
| N | Repeat search reverse |
| G | Go to last line |
| nG | Go to line n |
| :n | Go to line n |
| z<CR> | Reposition window: cursor at top |
| Reposition window: cursor in middle | |
| z- | Reposition window: cursor at bottom |