## Modes | Key | Command | | --- | --- | `esc` | normal mode | | `v` | view mode | | `i` | insert mode | ## Movements (Normal & Visual Mode) | Key | Command | Note | | --- | --- | --- | `j`, `k`, `h`, `l` | up, down, left, right | | `0`, `_` | go to start of line, go to first non-space character in line | | `
| go to end of line | | `/`, `?` | search forward, search backwards | `n` for next, or `N` to reverse | | `gg`, `G` | move to first line, move to last line | | `Ctrl` + `e`, `d`, `f`; `Ctrl` + `y`, `u`, `b` | scroll down 1 line, half screen, full screen; scroll up 1 line, half screen full screen | | `*`, `#` | highlight / go to next occurrence of word, same but backwards | | `f`, `F` | forward to character, backwards to character | `;` to repeat, `,` to reverse | | `t`, `T` | forward to 1 before character, backwards to 1 before (after) character | `;` to repeat, `,` to reverse | | `I`, `A` | insert at beginning of line, insert at end of line | | `{`, `}` | move up a paragraph, move down a paragraph | a "paragraph" is a collection of lines without white space | | `%` | jump to matching / opposing bracket, parenthesis, brace | ## Normal Mode | Key | Command | Notes | | --- | --- | --- | `o`, `O` | insert line below, insert line above | Enters insert mode | | `p`, `P` | paste, paste before cursor | | `"+p`, `"+y` | paste from system clipboard, yank to system clipboard | | `a`, `A` | append text, append text at end of line | Enters insert mode | | `:q`, `:wq`, `:q!` | exit, save and exit, exit and discard changes | | `d`, `dd` | delete selection, delete line | ## Visual Mode | Key | Command | Notes | | --- | --- | --- | `o` | go to other end of selection | While text is selected | | `i` | go to "visual inner" selection mode | E.g. `i(` will select everything inside the current set of parentheses, or `iw` will select the currently selected word | | `a` | go to "visual around" selection mode | Similar to `i` but does surrounding whitespace, parentheses, brackets, etc. | ## Command Mode NB: Each key here "starts" with `:`, but that just enters command mode | Key | Command | Notes | | --- | --- | --- | `%y+` | copy all content | | `set ic`, `set noic` | "ignore case" for the next search - 1-time setting, set "no ignore case" | | `set ignorecase` | ignore case for all searches | | `set smartcase` | do smartcase searching for next search | | `set rnu`, `set relativenumber` | set relative lines | | `Ex`, `Sex`, `Vex`, `Lex` | Go to explorer with split, vertical split, left explorer | Alternatively use `<C-w>s` and `<C-w>v` | | `nnoremap j jzz`, `nnoremap k kzz` | Have current line always scrolled into the center of the screen | | `s` | substitute on current line | "search / replace" | | `%s` | substitute in current file | "search / replace" | | `%y` | copy entire file | | `%y+` | copy entire file to system clipboard | | `%d` | delete entire file | | `nohlsearch` \| `noh` | unset highlighting after search | Highlighting will return on the next search unless you `set nohlsearch` in `.vimrc` | ## Marks 1. Set a mark with `m` in Normal Mode and a lowercase letter (a-z) 2. Jump to the mark's line later with `'` followed by the letter, or to the mark's exact position with `` ` `` followed by the letter. 3. If you want to see your current marks - `:marks`