Cheatography
https://cheatography.com
Vim Configuration - This is a description of the shortcuts I use the most in my vim configuration. Note that some of this shortcuts might have been remaped and might not work in a vanilla vim configuration unless the .vimrc is changed accordingly.
Cursor Movementsh, j, k, l | left, up, down, right | Ctrl + U/D | move a bunch of lines up/down | w, W | jump forwards to the start of a word (can contain punctuation) | e, E | jump forwards to the end of a word (can contain punctuation) | b, B | jump backwards to the start of a word (can contain punctuation) | ^ | jump to first non-blank character of the line | 0, $ | jump to start/end of line | gg, G | go to first/last line of the file | 5G | go to line 5 |
Inserting/Appending Texti | insert before the cursor | I | insert at the beggining of the line | a | append text after cursor | A | append text at end of line | o | open a new line below current line | O | open a new line above current line |
Marking text - Visual modev | start visual mode | V | linewise visual mode | Ctrl+v | start visual block mode | o | move to the other end of marked area | O | move to other corner of block | ab / aB | mark a block with () / {} | ib / iB | mark inner block with () / {} |
Visual commandsTab / S-Tab | shift text right / left | y | yank text (copy) | d | delete text | ~ | switch case |
Editingr | replace a single character | J | join line below to current one | cc | change entire line | cw | change to end of the word | c$ | change to end of line | cib/B | change inside () / {} | cab/B | change () / {} whole block | s | delete character and substitute text | S | same as cc | u / Ctrl-r | undo / redo | . | repeat last command | S-Up / S-Down | move current line up / down |
Cut and pasteyy | yank a line | yw | yank a word | y$ | yank until end of line | p / P | paste after/before cursor | dd | delete a line | dw | delete a word | D | delete to the end of the line | x | delete single character |
Search and replace/pattern | search pattern | ?pattern | search pattern backwards | n / N | repeat search in same / opposite direction | <Leader>h | clear search highlight | :%s/old/new/g | replace | :%s/old/new/gc | replace with confirmations |
Splits ManagementCtrl + i/j/k/l | move between splits | <Leader> +/- | increase / decrease current split vertical size | <Leader> </> | decrease / increase current split horizontal size | <Leader> << | set horizontal size to 85 (ideal for 80 characters long lines) | <Leader> mm | maximize current buffer vertically | Ctrl+w = | equalize sizes | :sp file/path | open file in new horizontal split | :vsp file/path | open file in new vertical split |
colon magic, / ; | they input :, so we don't need to shift |
Navigating the docs:h/:help Name | open docs about Name | Ctrl+5 | follow hyperlink | Ctrl+t | go back from hyperlink jump |
Foldszc/zo/za | close/open/toggle fold | zC/zO/zA | close/open/toggle fold on all levels | zR | set fold level to 0 (unfold everything) |
Function Keys MappingF2 | pastetoggle | F3 | NERDTree toggle | F4 | SyntasticCheck | F5 | Gundo Toogle | F9 | Run script |
Registers"{regname}y | yank into {regname} register. {regname} can be any letter. | "{regname}p | paste from {regname} register. | 0 register | only populated whenever you yank smth, not when you delete |
Tabs:tabedit {file} | open file in new tab | :tabfind {file} | find file in current path and open it in a new tab | :tabclose | close current tab | :tabclose {i} | close ith tab | :tabonly | close all tabs except current one | gt / gT | go to next / previous tab | {i}gt | go to ith tab | :tabm {i} | move current tab to ith position | :tabs | list all tabs and the files they include |
Variable case manipulation<Leader>kk | Change word under the cursor / visually selected variable from under_score_name to underScoreName |
| | UltiSnipsCtrl-j | expand snippet | :UltiSnipsEdit | edit snipets |
Tabular (visual mode edits only selection):Tabularize /pattern | use pattern to align text |
CtrlPCtrl-p | enter fuzzy search mode | F5 | reload cache | Ctrl-d | switch to search filenames mode | Ctrl-r | switch to regex mode | Ctrl-j / Ctrl-k | navigate search results | Ctrl-t | open result in new tab | Ctrl-x / Ctrl-v | open result in horizontal / vertical split | Ctrl-f | change mode ('line' for searching inside files, 'dir' for searching directories) |
NerdTree:NERDTree [directory] | open the directory tree | :NERDTreeClose | close it | [g]o | [leave cursor in tree] open files / directories | [g]i | [leave cursor in tree] open file in horizontal split | [g]s | [leave cursor in tree] open file in vertical split | e | edit current directory | P | jump to root node | p | jump to parent node | I | toggle display hidden files | m | open menu (create files/dirs, etc) |
NERDCommenter<Leader>c<Leader> | toggle comment | <Leader>cc | force comment | <Leader>cA | add a comment at the end of the line | <Leader>c$ | comment from cursor position to the end of line |
r-pluginall shortcuts | | <LL>rf | start R | <LL>ss | send selection to R (quiet) | <LL>se | send selection to R (echo the code) | <LL>sa | send selection to R (echo it) and then move down | <LL>l | send line to R | <LL>d | send line to R and then move down | <LL>aa | send whole file to r | <LL>ae | send whole file to R (echo it) | <LL>ro | show/update object browser |
vim-session - reopens tabs/buffer configuration:SessionSave {name} | saves session | :SessionOpen {name} | opens session (has tab completion) | :SessionClose | closes current opened session | :DeleteSession {name} | deletes a saved session | vim --servername {name} | opens session on vim opening |
Closetag.vim<Ctrl>_ | close last opened html/xml tag |
django.vim - syntax htmldjango files:setfiletype htmldjango | change current file syntax to django |
vim-exchange - text exchange operatorcx{motion} | On the first use, define the first {motion} to exchange. On the second use, define the second {motion} and perform the exchange. | X | cx for visual mode | cxc | clear current marked motion | . | Repeats first exchange {motion} |
vim-surroundcs{symbol1}{symbol2} | Change surroundings of current word from {symbol1} to {symbol2}. Ej: cs"', from "word" to 'word'. | ds{symbol} | Remove surrounding {symbol} from current word. Eg. ds" "word" -> word | ys{textobject}{symbol} | Surround word selected by {textobject} with {symbol}. Eg. ysiw" on Hel|lo world = "Hello" world |
vim-multiple-cursorsctrl+n | place a cursor, repeat for placing another cursor to next occurrence of the word. In visual mode, place a cursor per line. | v | after using ctrl+n, insert commands to edit all cursors at the same time. Multiletter commands such as dw or ciw don't work. |
|
Created By
Metadata
Favourited By
Comments
No comments yet. Add yours below!
Add a Comment
Related Cheat Sheets