Homepage
Amazon.com Wish List
Ole Miss on Google Maps
Tags for this wiki
Most Recent Changes
Have a question about anything on this site?
E-mail me at ![]()
I have an alias which points "vi" to "vim -p". The "-p" option turns on tabbing. Buffers and Tabs are the same thing in VIM: both allow you to have multiple files open in one VIM session. The only difference is how they are displayed on the screen and the short cuts used to move between files. Because tabs in VIM closely resemble tabs in Firefox, I tend to use tabs.
Also: I have uploaded my vimrc configuration file.
| h | move left |
| j | move down |
| k | move up |
| l | move right |
| w | jump by start of words (punctuation considered words) |
| W | jump by words (spaces separate words) |
| e | jump to end of current word (punctuation considered words) |
| E | jump to end of current word (no punctuation) |
| b | jump backward by words (punctuation considered words) |
| B | jump backward by words (no punctuation) |
| ( | jump to start of current sentence. |
| ) | jump to start of next sentence. |
| 0 | (zero) start of line |
| ^ | first non-blank character of line |
| $ | end of line |
| (number)G | Go to line (number). (Leave off number for last line of file.) |
Note: Prefix a cursor movement command with a number to repeat it. For example, 4j moves down 4 lines.
| 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 |
| r | replace a single character (does not use insert mode) |
| J | join line below to the current one |
| cc | change (replace) an entire line |
| cw | change (replace) to the end of word |
| c$ | change (replace) to the end of line |
| s | delete character at cursor and subsitute text |
| S | delete line at cursor and substitute text (same as cc) |
| xp | transpose two letters (delete and paste, technically) |
| u | Undo |
| ctrl+r | Redo |
| . | repeat last command |
| r filename | Insert filename into the current buffer. |
| r !command | Execute command and insert the output into the current buffer. |
| v | start visual mode, mark lines, then do command (such as y-yank) |
| V | start Linewise visual mode |
| > | shift right |
| < | shift left |
| y | yank (copy) marked text |
| d | delete marked text |
| u | Change selected text to lowercase |
| U | Change selected text to lowercase |
| ~ | switch case for selected text |
| o | move to other end of marked area |
| Ctrl+v | start visual block mode |
| O | move to Other corner of block |
| aw | select a word |
| ab | select a () block (with braces) |
| aB | select a {} block (with brackets) |
| ib | select inner () block |
| iB | select inner {} block |
| Esc | exit visual mode |
| yy | yank (copy) a line |
| 2yy | yank 2 lines |
| yw | yank word |
| y$ | yank to end of line |
| p | put (paste) the clipboard after cursor |
| P | put (paste) before cursor |
| dd | delete (cut) a line |
| dw | delete (cut) the current word |
| d( | delete (cut) beginning of sentence to current cursor position. |
| d) | delete (cut) current cursor position to end of sentence. |
| x | delete (cut) current character |
| :e filename | Edit a file in current buffer |
| :e directory | Open directory in interactive window to select file |
| :e . | Open current directory in interactive window to select file |
| :w | Write (save) the file, but don't exit |
| :w! | Write to a document that was opened in read-only mode |
| :wq (or ZZ) | Write (save) and quit |
| :q | Quit. Only works if document has not changed. |
| :q! | Quit and throw away changes |
A range is something that denotes lines of text in a document. A "#" (pound sign) is used below to denote where you should type a number instead.
| % | Entire document |
| n,m | Lines n to m |
| 1,$ | Also means entire document |
| . | The current line of the cursor only |
| 1,. | The start of the document to the current line. |
| .,$ | The current line to the end of the document |
| +# | The nth line after the current line of the cursor |
| -# | The nth line before the current line of the cursor |
| .,+3 | The current line plus the next three lines (4 lines total) |
| g/regex/ | Each line containing this regular expression |
| g/regex/+# | The nth line after each line containing this regular expression |
| m(label) | Marks current cursor position |
| '(label) | Reference label (To be used in some command context.) |
| g'(label) | Move cursor to label |
| d'(label) | Delete from current line to label |
| y'(label) | Yank from cursor to label position |
| p'(label) | Paste the yanked text after the label position |
| /pattern | Search for pattern |
| ?pattern | Search backward for pattern |
| f(character) | Search forward for character on current line. (Great for long lines.) |
| F(character) | Search backward for character. (Great for long lines.) |
| n | Repeat search in same direction |
| N | Repeat search in opposite direction |
| :%s/old/new/g | Replace all old with new throughout file (% can be replaced with any range) |
| :%s/old/new/gc | Replace all old with new throughout file with confirmations (% can be replaced with any range) |
| :bnext (or :bn) | Go to next buffer |
| :bprev (or :bp) | Go to previous buffer |
| :bd | Delete a buffer (close a file) |
| :bufdo | Prefix this to any VIM command to run in all buffers |
| :sp filename | Open a file in a new buffer and split window |
| ctrl+w s | Split windows |
| ctrl+w w | switch between windows |
| ctrl+w q | Quit a window |
| ctrl+w v | Split windows vertically |
| :tabn (or :tn or gt) | Go to next tab |
| :tabp (or :tp or gT) | Go to previous tab |
| :tabfirst (or :tabfir) | Go to first tab |
| :tablast | Go to last tab |
| :tabedit (or :tabe) | Open a new tab |
| :tabedit filename (or :tabe filename) | Open a new tab with filename |
| :tabdo | Prefix this to any VIM command to run in all tabs |
To use folds as soon as the program starts, you need to set up your "vimrc" file correctly with "set foldenabled".
By default, the fold markers are "{{{" for beginning and "}}}" for end. I thought folds would improve my programming abilities, but the more I used them, the more I felt they got in the way.
| :%fold (or :%fo) | Fold entire document. The % can be replaced with any range. |
| zf#j | Creates a fold from the cursor down # lines. |
| zf/string | String creates a fold from the cursor to string. |
| zj | Moves the cursor to the next fold. |
| zk | Moves the cursor to the previous fold. |
| zo | Opens a fold at the cursor. |
| zO | Opens all folds at the cursor. |
| zm | Increases the foldlevel by one. |
| zM | Closes all open folds. |
| zr | Decreases the foldlevel by one. |
| zR | Decreases the foldlevel to zero -- all folds will be open. |
| zd | Deletes the fold at the cursor. |
| zE | Deletes all folds. |
| [z | Move to start of open fold. |
| ]z | Move to end of open fold. |
To use the spell checker, you need to set up your "vimrc" file correctly with "set spell". I typically use just "z=" and don't mess with the other options.
| z= | Suggest a new spelling for a misspelled word. |
| ]s | Move to next misspelled word. |
| s[ | Move to previous misspelled word. |
| zg | Permanently add word to word list. |
| zG | Temporarily add word to word list. Word is forgotten when vim closes. |
| zw | Permanently mark word as bad. |
| zW | Temporarily make word as bad. |
| zug | Undo zg: Remove word from permanent word list. |
| zuG | Undo zG: Remove word from temporary word list. |
| zuw | Undo zw: Remove bad word marking from permanent list. |
| zuW | Undo zW: Remove bad word marking from temporary list. |
Page Information
|
Wiki Information |
Recent PBwiki Blog Posts |