This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
user:afassett:hcp_projects:vimtut [2010/12/17 00:19] – created afassett | user:afassett:hcp_projects:vimtut [2010/12/17 03:24] (current) – afassett | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Vim Tutorial ====== | ||
+ | ===== Opening Vim ===== | ||
+ | A plain ol' vim opening | ||
+ | <cli> lab46:~$ vim </ | ||
+ | |||
+ | To open a file in vim with the filename file | ||
+ | <cli> lab46:~$ vim file </ | ||
+ | |||
+ | The -o option adds the ability to open mutliple windows at once. N is the number of windows to open. Replace -o with -O if you want to open the windows vertically. This can also be done with previously saved files. Omit the N and enter the file names after the -o. | ||
+ | <cli> lab46:~$ vim -oN </ | ||
+ | |||
+ | ===== Saving in Vim ===== | ||
+ | * :q - exit with file unchaged | ||
+ | * :q! - exit and discard any changes to file | ||
+ | * :wq or :zz - save and quit - If you didn't specify a filename upon opening vim add the desired filename to either of these. | ||
+ | |||
+ | ===== Switching Modes ===== | ||
+ | *esc - enters command mode | ||
+ | *i - input mode - cursor at current position | ||
+ | *a - append - cursor at next character position | ||
+ | *o - places the cursor on the next line | ||
+ | *O - places the cursor on the previous line | ||
+ | ===== Command Mode ===== | ||
+ | ==== Moving Around ==== | ||
+ | *h - move left | ||
+ | *j - move down | ||
+ | *k - move up | ||
+ | *l - move right | ||
+ | *w - skip forward by word (punctuation considered) | ||
+ | *W - skip forward by word (punctuation not considered) | ||
+ | *b - skip backward by word (punctuation considered) | ||
+ | *B - skip backward by word (punctuation not considered) | ||
+ | *^ - move to the beginning of a line | ||
+ | *$ - move to the end of a line | ||
+ | *G - move to the last line of file | ||
+ | *nG- move to line number N | ||
+ | *v - begin selecting text for highlighting | ||
+ | *dd- cut the current line | ||
+ | *dw- cut the current word | ||
+ | *x - delete the current character | ||
+ | *yy- copy current line | ||
+ | *y$ - copy from current position to end of current line | ||
+ | *p - paste after cursor | ||
+ | *P - paste before cursor | ||
+ | *u - undo | ||
+ | */ - search | ||
+ | *n - move to next word in a search | ||
+ | *N - move to previous word in a search | ||
+ | |||
+ | ==== Random Commands ==== | ||
+ | *:set number - display all line numbers | ||
+ | *:syntax on - turns on syntax highlighting for scripting/ | ||
+ | *:set cursorline - places a bar under the current line | ||
+ | *:set autoindent - turns on auto indentation | ||
+ | *: | ||
+ | ====Advance==== | ||
+ | (Split screening) | ||
+ | Vim viewport keybinding quick reference | ||
+ | |||
+ | * :sp will split the Vim window horizontally. Can be written out entirely as :split . | ||
+ | * | ||
+ | * :vsp will split the Vim window vertically. Can be written out as :vsplit . | ||
+ | * | ||
+ | * Ctrl-w Ctrl-w moves between Vim viewports. | ||
+ | * | ||
+ | * Ctrl-w j moves one viewport down. | ||
+ | * | ||
+ | * Ctrl-w k moves one viewport up. | ||
+ | * | ||
+ | * Ctrl-w h moves one viewport to the left. | ||
+ | * | ||
+ | * Ctrl-w l moves one viewport to the right. | ||
+ | * | ||
+ | * Ctrl-w = tells Vim to resize viewports to be of equal size. | ||
+ | * | ||
+ | * Ctrl-w - reduce active viewport by one line. | ||
+ | * | ||
+ | * Ctrl-w + increase active viewport by one line. | ||
+ | * | ||
+ | * Ctrl-w q will close the active window. | ||
+ | * | ||
+ | * Ctrl-w r will rotate windows to the right. | ||
+ | * | ||
+ | * Ctrl-w R will rotate windows to the left. | ||
+ | |||
+ | ====Original source==== | ||
+ | [[http:// | ||