Home | Projects | Notes > Unix/Linux > Vim Cheat Sheet
xxxxxxxxxx111* :help keyword - open help for keyword2* :saveas file - save file as3* :close - close current pane4* K - open man page for word under the cursor5* Ctrl+g - show file name and relevant information6* :w newfile.txt.backup - create a backup file (still working in newfile.txt)7* :w newname.txt - write to a different file with newname8* :r file.txt - read in contents in file.txt and put it to cursor position9* :version - show the current vim version (:ver)10* :colorscheme - show the current vim colorscheme11               - :colorscheme+Tab - loop through selectable colorschemes
xxxxxxxxxx141[number] verb [number] <noun>2
3* d2w : [1 time] delete [2] <words>4* 2dw : [2 times] delete [1] <word>5* 2d3l : [2 times] delete [3] <characters to the right>6* 3d2l : [3 times] delete [2] <characters to the right>7* d6j : [1 time] delete [6] <lines>8* >l : [1 time] indent [current line]9* >h : [1 time] indent [current line]10* >j : indent current line and line below11* >> : indent current line12* 2>> : indent 2 lines13
14[!] Note: above mentioned '> (indent)' logic applies to '< (outdent)' as well
xxxxxxxxxx581* h - move cursor left (2h - move left two characters)2* j - move cursor down (2j - move down 2 lines)3* k - move cursor up4* l - move cursor right5* H - move to top of screen (High)6* M - move to middle of screen (Middle)7* L - move to bottom of screen (Low)8* w - jump forwards to the start of a word9* W - jump forwards to the start of a word (words can contain punctuation)10* e - jump forwards to the end of a word11* E - jump forwards to the end of a word (words can contain punctuation)12* b - jump backwards to the start of a word13* B - jump backwards to the start of a word (words can contain punctuation)14* ge - jump backwards to the end of a word15* % - move to matching character (default supported pairs: '()', '{}', '[]' -16      use ':h matchpairs' in vim for more info)17* 0 - jump to the start of the line18* ^ - jump to the first non-blank character of the line19* Home - jump to the start of the line20* $ - jump to the end of the line21* g_ - jump to the last non-blank character of the line22* End - jumb to the end of the line23* gg - go to the first line of the document24* G - go to the last line of the document25* Ctrl+Home - go to the first line of the document26* Ctrl+End - go to the last line of the document27* 5G - go to line 528* :5 - go to line 529* fx - FIND the next ocuerrence of character x30* Fx - FIND the previous occurence of character x31* tx - jump TO before next occurrence of character x32* Tx - jump TO after previous occuerence of character x33* ; - repeat previous f, t, F or T movement34* , - repeat previous f, t, F or T movement, backwards35* } - jump to next paragraph (or function/block, when editing code)36* { - jump to previous paragraph (or function/block, when editing code)37* Ctrl+e - move screen down on line (without moving cursor)38* Ctrl+y - move screen up one line (without moving cursor)   39* Ctrl+b - move back one page (full screen)40* Ctrl+f - move forward one page (full screen)41* 3+PgUp - go up 3 pages42* 3+PgDn - go down 3 pages43* Ctrl+d - move forward 1/2 a screen44* Ctrl+u - move back 1/2 a screen45* :set scrolloff=5 - set scroll offset to 5 (lines) - default is 'scrolloff=0'46* :set scrolloff=999 - set scroll offset to the middle of the screen47* 50% - move from the top down to the 50% into the file48* zt - take the current line to the top of the screen49* zz - take the current line to the center of the screen50* zb - take the current line to the bottom of the screen51* g; - go to the last (previous) change52* g, - go to the next (more recent) change53* :changes - show all changes made54* Ctrl+o - go to the previous jump55* Ctrl+i - go to the next more recent jump56* :jumps - show all jumps (searches, substitutes, finding marks...) 57         - [!] Note: scrolling through the file, paging or moving cursor58           up/down are NOT jumps
xxxxxxxxxx81* i - insert before the cursor2* I - insert at the beginning of the line3* a - insert (append) after the cursor4* A - insert (append) at the end of the line5* o - append (open) a new line below the current line6* O - append (open) a new line above the current line7* ea - insert (append) at the end of the word8* Esc - exit insert modexxxxxxxxxx241* r - replace a single character2* J - join line below to the current one without space in between3* gJ - join line below to the current one with a space in between4* gwip - reflow paragraph5* cc - change (replace) entire line6* C - change (replace) to the end of the line (D+i)7* C$ - change (replace) to the end of the line8* ciw - change (replace) entire word9      - the cut word replaces whatever there  was in the default register10* cw - change (replace) to the end of the word11* s - delete character and substitue text12* S - delete line and substitute text (same as cc)13* xp - transpose two letters (delete and paste)14* u - undo15* Ctrl+r - redo16* . - repeat last command17* R - enter replace(overwrite text) mode ('backspace' to undo)18* J - join the line below to the current line (J = 1J = 2J) 19* 3J - join next 2 lines to the current line (4J - ... next 3 lines...)20* :10,19sort - sort lines from line 10 to 1921* :10,19sort! - sort lines from line 10 to 19 in reverse order22* %sort - sort all lines in the current file23* %sort! -  sort all lines in the current file in reverse order24* :set list - show 'end of line ($)' characters xxxxxxxxxx381* Ctrl+a - increment the number by 12         - this works as long as the cursor is on the left to the number3* 5+Ctrl+a - repeat 'Ctrl+a' 5 times (increment the number by 5)4* Ctrl+x - decrement the number by 15         - this works as long as the cursor is on the left to the number6* g+Ctrl+a - set array indecies in increasing order7
8        myArray[0] = 0;                              myArray[0] = 0;9        myArray[0] = 0;  <--- select from here       myArray[1] = 0;10        myArray[0] = 0;                              myArray[2] = 0;11        myArray[0] = 0;                              myArray[3] = 0;12        myArray[0] = 0;                              myArray[4] = 0;13        myArray[0] = 0;         ---------->          myArray[5] = 0;14        myArray[0] = 0;                              myArray[6] = 0;15        myArray[0] = 0;                              myArray[7] = 0;16        myArray[0] = 0;                              myArray[8] = 0;17        myArray[0] = 0;                              myArray[9] = 0;18        myArray[0] = 0; <--- to here                 myArray[10] = 0;19 20* :put =range(10,15) - put range of numbers vertically from the next line of21                       current cursor position22* :12put =range(10,15) - put range of numbers vertically from the next line of23                       user specified line 12 (which is line 13)24* :0put =range(10,15) - put rnage of numbers vertically from the beginning of25                        the file26* :$put =range(10,15) - put rnage of numbers vertically at the bottom of the27                        file28* :for i in range(115,120) | put = '192.168.0.'.i | endfor29                    - putting sequential IP addresses using for loop30                    - .i means put in the range user specified31* :%s/^/\=print('%-4d', line('.')) - insert line numbers in the entire file32                                     (numbers are left justified)33                                   - 's' means substitute34                                   - '^' means beginning of the file35* :%s/^/\=print('%4d', line('.')) - insert numbers right justified36                                  - '%4-d' -> '%4d'37* :%s/^/\=print('%04d', line('.')) - insert numbers right justified and zero38                                     filled (leading zeros)xxxxxxxxxx251* yy - yank (copy) a line (and save it in memory)2* Y - yank (copy) a line3* 2yy - yank (copy) 2 lines4* y2w - yank (copy) 2 words5* yw - yank (copy) the characters of the word from the cursor position to the6       start of the next word7* yi{ - yank (copy) in curly braces8* y$ - yank (copy) to end of line9* p - put (paste) the clipboard after cursor10* 2p - put (paste) the clipboard after cursor twice11* P - put (paste) before cursor 12* Ctrl+r " - paste from default register (in insert mode) 13* dd - delete (cut) a line14* 2dd - delete (cut) 2 lines15* dw - delete (cut) the characters of the word from the cursor position to16       the start of the next word17* D - delete (cut) from the cursor to the end of the line18* 2D - delete to end of line and the next line19* dip - delete in paragraph 20* d$ - delete (cut) to the end of the line21* dt. - delete TO the '.'22* d/pattern - delete from the cursor to pattern23* d?pattern - delete from the cursor to pattern backwards (including pattern)24* x - delete (cut) character25* :set Paste - pastes text in alignment(not needed on updated versions of vim)xxxxxxxxxx391* * - search forwarad for current pattern2* # - search backward for current pattern3* /pattern - search for pattern4* /\cpattern - search for pattern case insensitive5* /\Cpattern - search for pattern case sensitive6* /\<pattern\> - search for independent pattern (surrounded by spaces)7* /\/\* - search for '/*' (escaping special characters)8* ?pattern - search backward for pattern9* ?\cpattern - search backward for pattern case insensitive10* ?\Cpattern - search backward for pattern case sensitive11* \vpattern - 'very magic' pattern: non-alphanumeric characters are interpreted12              as special regex symbols (no escaping needed)13* n - repeat search in same direction14* N - repeat search in opposite direction15* :4,7s/old/new - replace all old with new from line 4 to 716* :%s/old/new - replace all old with new throughout(%s) file17* :%s/\<old\>/new - replace all independent old with new throughout(%s) file18* :%s/old/new/g - ... globally19* :%s/old/new/gc - ...globally with confirmations (see confirmation msg below)20      - replace with new (y/n/a/q/l/^E/^Y)?21        y - yes22        n - no23        a - all after current cursor position24        q - quit25        l - make this the last change and quit (yq) 26        ^E - scroll down until current cursor position hits top of screen 27        ^Y - scroll up until current cursor position hits bottom of screen 28* :%s/old/new/gic - ...globally with confirmations case insensitive29* :%s/old/new/gIc - ...globally with confirmations case sensitive30* :set hlsearch - turn on search highlighting (:set hl)31* :set nohlsearch - turn off search highlighing (:set nohl, :set noh)32* :set incsearch - turn on incrememtal search highlighting33* :set noincsearch - turn off incrememtal search highlighting34* /[arrow up] - search through forward search history35* ?[arrow up] - search through backward search history36* :[arrow up] - search through command history37* q/ - show forward search history (records are editable)38* q? - show backward search history (records are editable)39* q: - show command history (records are editable)xxxxxxxxxx3811. ENTER VISUAL MODE2====================3
4* Ctrl+v  start visual mode, mark lines, then do a command (like y-yank)5* V       start linewise visual mode6
72. SELECT AREA8==============9
10* $ - select to the end of the line11* aw - mark a word12* ab - a block with ()13* aB - a block with {}14* iw - select current word under cursor15* i+parenthesis - select everything inside parenthesis (e.g. vi(, vi{, vi[)16* iB - select everything inside block (curly braces), same as vi{17* ib - inner block with ()18* iB - inner block with {}19
203. TAKE ACTION21==============22
23* o - move to other end of marked area24* I - insert text to the left of visual block25* A - append to the right of the visual block26* c - change visual block (delete the block and insert new text to the block)27* d - delete visual block 28* 0 - move to other corner of block29* > - shift text right30* < - shift text left31* y - yank (copy) marked text32* d - delete marked text33* ~ - switch case34* w - mark to before the start of next word35* e - mark to the end of a word36* fed - find and mark to the letter 'e' and delete the marked text37* fey - find and mark to the letter 'e' and yank the marked text38* Esc - exit visual mode
xxxxxxxxxx131* :set list - show invisible characters (^I: Tab, $: end of line)2* :set expandtab - set to insert spaces instead of tab character3                 - ':set noexpandtab' to unset4* :set shiftwidth - show current shiftwidth value5* :set shiftwidth=4 - set shift width to 4 (:set sw=4)6* :set tabstop - show current tabstop value7* :set tabstop=4 - set tabstop to 4 (:set ts=4)8                 - if tabstop=8 and shiftwidth=4, tab character will appear9                   when shift happens twice10* :set softtabstop - show current shofttabstop value11                   - ':set softtabstop=0' use tabstop value as a default12* :filetype - check to see if vim is detecting file types13            - [!] Note: for filetype indent setting, see '.vimrc' sectionxxxxxxxxxx81* >> - indent a single line2* << - outdent a single line3* 4>> - indent the current line and the 3lines below it4* 4<< - outdent the current line and the 3lines below it5* 14== - auto-format 14 lines from the current line6[!] Note: ':e $VIMRUNTIME/indent' to see the file vim refers to for filetype7          auto-formatting information (depending on the version, this path may8          point to a different locationxxxxxxxxxx51* Tab - indent2* Ctrl+v u0009 - insert a tab character3* Ctrl+v Ctrl+i - insert a tab character4* Backspace - outdent5[!] Note: to change tab character to a single character, see '.vimrc' sectionxxxxxxxxxx21* (visually selected block) > - indent selected block2* (visually selected block) = - auto-foramt (auto indent)
xxxxxxxxxx341little storage places where you can yank text and keep it for later2(registers we can yank in to are: a - z)3
4* :register - show registers content (:reg)5            - ": - special register for the last command user typed6            - "/ - special register for the path directory7            - "% - special register for the document name 8            - ". - register for last command9            - "0 - last yanked register10                 - when an entire line is yanked, '^j' character is appended at11                   the end of the yanked line in the register12            - "" - default register13            - "- - register for the last deleted text (dash/hyphen register)14                 - when an entire line is deleted, it is saved in both '""' and15                   '"1' registers. numbered registers will keep bumped down and16                   down until it gets to '"9' (there's no '"10' register so17                   after '"9' register, it will be lost)18            - "a - user specified register 'a'19            [!] Note: when we yank text, it is saved in both '"0' and '""'20* "/p  a  Ctrl+r %  Ctrl+r : - print 'dir', 'doc name', 'last command'21* "ay - yank into register a (each letter on the keyboard corresponds to22        different registers)23* "ayiw - yank in word to register 'a' (as well as to the default register)24* "ap - paste contents of register 'a'25* Ctrl+r " - paste from default register (in insert mode) 26* Ctrl+r a - paste contents of register 'a' (in insert mode) 27* Ctrl+r Ay - append and yank into register 'a'28* ciw - change (replace) entire word29      - the cut word replaces whatever there  was in the default register30      - 'Ctrl+r a' will replace the original word with the contents of reg 'a' 31* to clear all the registers???32[!] Note: registers are being stored in ~/.viminfo, and will be loaded again on33          next restart of vim.34[!] Note: Register 0 contains always the value of the last yank command. 
xxxxxxxxxx211bookmarks2
3* :marks - list of marks4* ma - set current position for mark 'a'5* `a - jump to the position of mark 'a' in the line marked6* 'a - jump to line with mark 'a' (NOT to the position where mark was placed)7* y`a - yank text to position of mark 'a'8* [' - jump to the previous mark line9* ]' - jump to the next mark line10* [` - jump to the previous mark11* ]` - jump to the next mark12* d'a - delete to the line with mark 'a'13* y'a - yank (copy) from cursor to the mark 'a' (then bring cursor to the top14        of the selection / '] to go to the bottom of the selection)15* mA - set current position for mark 'A' (uppercase works the same way as the16       lower case works as long as you are in the same file, mark with17       uppercase can be referenced from a different file)18* (in another file) 'A - open file and go to the mark 'A'19* :delmarks a,A,C - delete marks 'a', 'A', 'C'20* :delmarks A-Z - delete marks from 'A' to 'Z'21* :delmarks! - delete all marks
xxxxxxxxxx91vim macro feature allows you to record and play a sequence of actions inside of2the vim editor (macros are stored in registers a-z)3
4* qa - start recording a macro into the register 'a'5* q - stop recording macro6* @a - run macro stored in the register 'a'7* 3@a - run macro stored in the register 'a' 3 times8* @@ - return last run macro9* :let @b='05^Xj' - setting '5Ctrl+x' to macro(register) 'b'xxxxxxxxxx61* :w - write (save) the file, but don't exit2* :w !sudo tee % - write out the current file using sudo3* :wq - write (save) and quit (:x, ZZ)4* :q - quit (fails if there are unsaved changes)5* :q! - quit and throw away unsaved changes (ZQ)6* wqa - write (save) and quit on all tabs
xxxxxxxxxx121
2* :vimgrep /pattern/ {`{file}`} - search for pattern in multiple files 3                                  (e.g. :vimrgrep /foo/ ??/?)4* cn - jump to the next match5* cp - jump to the previous match6* copen - open a window containing the list of matches7* :e file - edit a file in a new buffer8* :bnext - go to the next buffer (:bn)9* :bprev - go to the previous buffer (:bp)10* :bd - delete a buffer (close a file)11* :ls - list all open buffers12* :r file - read file content (insert text content of file below the cursor)xxxxxxxxxx341* :split - split window horizontally (:new, :sp)2* :vsplit - split window vertically (:vnew, :vsp)3* :sp file - open a file in a new buffer and split window4* :vsp file - open a file in a new buffer and vertically split window5* :set splitright - set to make the split show up on the right6* :enew - open new file in the current window7* Ctrl+w s - split window8* Ctrl+w v - split window vertically9* Ctrl+w w - switch windows10* Ctrl+w x - swap window position11* Ctrl+w r - rotate windows12* Ctrl+w R - rotate windows in opposite direction13* Ctrl+w t - go to the top left window14* Ctrl+w b - go to the bottom right window15* Ctrl+w p - go to the previous window16* Ctrl+w o - show only the active window (others still remain in buffer)17* :ba - bring all buffers to split windows (horizontal)18* :vert ba - bring all buffers to split windows (vertical)19* :vert 3ba - show all buffers up to buffer 3 (vertical)20* :vsp | b3 - split buffer 3 (vertical)21            - if '|' is omitted, vim will try to split and open a file named b322* Ctrl+w q - quit a window23* Ctrl+w h - move cursor to the left window (vertical split)24* Ctrl+w l - move cursor to the right window (vertical split)25* Ctrl+w j - move cursor to the window below (horizontal split)26* Ctrl+w k - move cursor to the window above (horizontal split)27* :resize 20 - resize the current window to 20 (horizontal)28* :resize -5 - downsize 5 the current window (horizontal)29* :vertical resize 80 - resize thecurrent window to 80 (vertical)30* :vertical resize +25 - resize +25 the current window (vertical)31* Ctrl+w = - make all windows the same size32* Ctrl+w _ - max current window height33* Ctrl+w | - max current window width34* :help ctrl-w - show everything you can do with 'Ctrl+w'xxxxxxxxxx171piece of memory in RAM2
3* :buffers - show all buffer info (:ls)4    - %a    currently active buffer5    - #     alternate buffer (where you just came from)6    - h     hidden buffer7    - +     buffer has unsaved changes8* :e filename.txt - open up 'filename.txt' (will be added to 'buffers' list)9* :bp - buffer previous (':bp!' force command)10* :bn - buffer next11* :set hidden - hide buffer (hidden setting applies to all files in buffer)12              - ':set nohidden' to unset13* b4 - jump to buffer 414* Ctrl+6 - toggle back and forth between the current and alternate buffers15* Ctrl+^ - toggle back and forth between the current and alternate buffers16* :bd - delete this buffer17* e! - remove all the changes since the last save
xxxxxxxxxx291* :tabeddit filename.txt - open and eddit a file in a new tab (:tabe)2                         - same file can be opened in multiple tabs3* :tabnew or :tabnew {page.words.file} - open a file in a new tab4* :tabnext - go to the next tab (to the right and loop around) (:tabn, :gt)5* :3gt - go 3 tabs right6* Ctrl+PgUp - go to the next tab7* :tabnext 3 - go to the right 3 tabs8* :tabprev - go to the previous tab (to the left and loop around) (:tabp, :gT)9* :3gT - go 3 tabs left10* Ctrl+PgDn - go to tne previous tab11* Ctrl+wT - move the current split window into its own tab12* :tab split - split a window into a new tab (without removing the original)13* :tabmove # - move current tab to the #th position (indexed from 0) (:tabm #)14* :tabm - move current tab to the far right15* :tab 0 - move current tab to the far left16* :w newname.txt - name the file and save 17* :tabclose - close the current tab and all its windows (:tabc)18            - but they still remain in buffer19* :tabclose 3 - close the tab 320* :tab ball - open all buffers each in its own tab21* :set tabpagemax=9 - set tab page max value to 922* :tabonly - close all tabs except for the current one (:tabo)23* :drop file.txt - drop the current file and open file.txt in the current tab 24                 - if file.txt is already open in one of the tabs, current file25                   does not drop and it just goes to the file.txt tab26* :tabdo command - run the command on all tabs (e.g. :tabdo q - closes all27                   opened tabs)28[!] Note: when a tab contains multiple split windows, the tab name will change29          depending on selected window
xxxxxxxxxx111* :set wrap - word wrap2* :set linebreak - break lines at words3* :set cursorline - highlight current line4* :set colorcolumn=x - show vertical line where 'x' is the column number5* :set list - show all whitespaces6* :set textwidth=x - automatic word wrapping (text wraps automatically as you7  type, in order to make each line long 'x' characters at most)8* :set number (:set nu)9* :set nonumber (:set nonu)10* :set relativenumber (:set rnu)11* :set norelativenumber(:set nornu)xxxxxxxxxx591the way of hiding text from view2
3* :set foldmethod - show current foldmethod (:set fdm)4                  - 'manual' is default and most popular (folds must be defined5                    by entering commands; like 'zf')6                  - 'indent' creates a fold for each indent7                  - 'syntax' creates a fold by the syntax of a programming8                    language 9                  - 'expr' folds are created by a user-defined expression (like10                    a regex / regular expression)11                  - 'marker' creates folds for start and end characters a user12                    defines13                  - 'diff' is used to fold unchanged text when viewing14                    differences (automatically set in diff mode)15                    16FOLDMODE=MANUAL17===============18
19* (visually select text block) zf - create a fold20* zf10j - fold up current line + next 10 lines21* zf10k - fold up current line + prev 10 lines22* :148,158fold - fold the designated scope of lines23                 (:148,158 fold, :148,158 fo) 24* :,+10 fo - fold current line + next 10 lines25* :,-10 fo - fold current line + prev 10 lines26* :zfa{ - create a fold between { and } (line wise)27* zo - open up a fold28* zO - open the fold and all the nested folds29* zn - open up all folds30* :86, 136 foldopen - open up folds located in lines 86 ~ 13631                    - to retrieve the last line of the file 'Ctrl+g'32* :86, 136 foldclose - close folds located in lines 86 ~ 13633* :% foldopen - open up all the folds in current file ('%' means 'everything')34* :% foldclose - close all the folds in current file ('%' means 'everything')35* zN - set all folds as they were before executing zn command36* zj - go to the next fold37* zk - go to the prev fold (last line of the previous fold)38* [z - go to the top of the current fold39* ]z - go to the bottom of the current fold40* zc - close fold41* zd - delete fold42* zC - close this fold and all folds it is nested in43* zA - toggle between zC and zO44* zE - eliminate all folds from the curent file45* :mkview - save a fold (saved folds goes to '~/.vim/vim')46          - vim does not remember unsaved folds47* :loadview - load the saved views48            - saved views must be loaded to show up49[!] Note: make this process easier by adding commands to .vimrc50
51
52FOLDMODE=INDENT53===============54
55* :set fdm=indent - fold up all indented texts56* zr - reduce all folds one level (same as 'zo' for all the nested folds)57* zR - reduce all folds in the file58* zm - fold up all folds one level (same as 'zc' for all folds)59* zM - fold up all folds all the way (same as 'zC' for all folds)
Built in vim v7.0 or higher
xxxxxxxxxx811* vim [directory] - open the directory with vim's built in file explorer2                    plugin('NetRW') and show what is in that directory3* vim . - go to the file explorer in the current directory4        - vim's file explorer shows hidden files by default (can hide them)5* /[file/directory] - find file or directory in vim's file explorer6* - - go up one directory level (or hit enter on '../')7* :q - quit out of the file explorer8* D - delete a file or directory with confirmation9* R - rename a file or directory10* s - sort files or directories11* x - open the file with linux's default text editor12* % - create a file13* d - crate a directory14* gh - hide hidden files ('Hiding' will appear on the header)15     - 'gh' again will toggle the hidden files back on16* I - hide the header17    - 'I' again will toggle the header back on18* o - open the file in a split window (new split window is placed on the top,19      cursor is in that window)20* v - open the file in a vertial split window (new split window is placed on21      the left, cursor is in that window)22      that window)23* :let g:netrw altv=1 - set to open the split to the right24* p - preview the file (cursor stays on explorer window, 'Ctrl+w w' to go to25      the preview window)26* Vex - split back into the vertical explorer window27* Sex - split back into the horizontal explorer window28
29HEADER INFO30===========31
32* Netwr Directory Listing (netrw v156)33    - NetRW plugin version info34* /home/kyungjae-lee/linux 35    - current working directory36* Sorted by 37    - how the directory is sorted (hit 'enter' on the line or hit 's' anywhere38      in the file explorer to change)39        - name40        - size41        - exten(sion)42* Sort sequence43    - hit 'enter' on the line or hit 'S' anywhere in the file explorer to edit44      the sequence45* Quick Help46    - hit 'enter' on the line and the quick help menu will loop around47    - also can enter Quick Help by executing ':help quickhelp'48
49COPY and MOVE50=============51copy a file or group of files from the current directory to another52
531. mark the target directory54    - put cursor to the target directory-to-bo and55    - mt56    - 'Copy/Move Tgt:' will newly appear on the file explorer header57
582. mark a file or files to copy59    - mf (make sure the file name is bold or highlighted)60
613. copy the files62    - mc (if successful, prviously highlighted file names will no longer be63      highlighted)64
65NetRW FIX FUZZY FIND66====================67* vim - enter vim68
69* r filename.txt - read in filename.txt70* e filename.txt - edit a filename.txt71* :find filename.txt - find a 'filename.txt' (subfolder that the target file is72                       located must be specified! to fix this see ':set path')73* :set path - show fuzzy search path (to make NetRW search all subdirectories and74              recursively, see '.vimrc' section)75            - ',' is a separator76* (after editing the 'path') find filename.txt - search filename.txt through77            all paths, spoting one by one as user hits 'Tab' key78* (when 'wildmenu' is set) find filename.txt + Enter - enter the first file79            that matches.80* (when 'wildmenu' is set) find filename.txt + Tab - loop though all the files81            that match. hit 'Enter' key to enter the target file.
xxxxxxxxxx131vim's built-in command for searching across multiple files2
3* :vimgrep /pattern/g % - search 'pattern' only in this open buffer(%)4                          (:vim /pattern/g %)5* :vimgrep /pattern/g **/* - search 'pattern' through the entire project dir.6                           - '.vimrc' must be updated for this to work. (see7                             'set path' in '.vimrc' section)8* :cope - (c open) show search result as a list (j, k to navigte, 'Enter' to go9          to the occurrence) (:cw)10* :cnext - go to the next match11* :cprev - go to the previous match12* :cfirst - go to the first match13* :clast - go to the last match
xxxxxxxxxx21* :help - to the main 'help' screen2* :help [command] - to the '[command]' section of the 'help' screen
xxxxxxxxxx51download plugins under the path '~/.vim/pluginname' 2    - make '~/.vim' directory if you don't have one3    - it's good to make designated 'pluginname' directory for each plugin4      (as long as '.vimrc' points to the right directory, there won't be any5      problems running plugins)xxxxxxxxxx1511. download 'badwikf-master.zip' from http://github.com/sjl/badwolf22. mkdir ~/.vim/color 3    - 'color' is user designated plugin directory name43. cd ~/.vim/color54. mv ~/Downloads/badwolf-master.zip .65. unzip badwolf-master.zip76. ls -lah8    - check if the unzip was successfully done97. cd ~108. vim .vimrc11    - set runtimepath^=~/.vim/color/badwolf-master129. :wq vim and re-enter so that vim applies the new updates1310. :colorscheme badwolf14    - badwolf color scheme is working!1511. to undo this color scheme change, comment out '9.', :wq and re-enter vimxxxxxxxxxx491https://vimawesome.com2some examples of plugin manager3    - Vundle4    - NeoBundle5    - VimPlug6    - Pathogen7
8VimPlug Manager9~~~~~~~~~~~~~~~10
111. download VimPlug manager from https://github.com/junegunn/vim-plug122. mkdir ~/.vim/autoload13    - 'autoload' is a special directory for vim. it's meant to delay loading14      the code until it's actually needed. this is to keep vim running fast.153. cd .vim/autoload164. mv ~/Downloads/vim-plug-master.zip .175. ls -lah186. unzip vim-plug-master.zip197. mv vim-plug-master/plug.vim . 208. cd (cd~)219. vim .vimrc22    - call plug#begin('~/.vim/plugged')23        - 'call' is telling vim to look in the .vim/autoload directory for the24          .vim file called 'plug'25        - '~/.vim/plugged' does not exist yet but vim will take care of it and26          this is where VimPlug will place the installed plugins27    - call plug#end()2810. go to https://vimawesome.com29    - go to Syntastic plugin30    - go to VimPlug31    - copy 'Plug ...' into .vimrc (between 'call plug#begin' and 'plug#end')3211. add a few more lines to .vimrc for Perl script (it is found that without33    following lines, perl script errors were not being detected correctly)34    - let g:syntastic_check_on_open         = 135    - let g:syntastic_check_on_wq           = 036    - let g:syntastic_enable_perl_checker   = 137    - let g:syntastic_perl_checkers         = [perl', 'podchecker']38    [!] Note: above lines of code simply means turning on the perl checker and39    telling syntastic what checker user wants to use4011. source .vimrc41    - it means to :wq and enter back in the .vimrc4212. :PlugInstall43    - install the plugin4413. quit out of plugins window, quit out of .vimrc45
46[!] Note: to clear the plugin, 47    - go to .vimrc and comment out everything but the ones we wrote at '9.'48    - :PlugClean 49        - this actually removes the plugin with confirmation
xxxxxxxxxx311vim's file compare feature that allows users to see the difference between 2 or23 files3
4* vimdiff file1.txt file2.txt 5    - open 'file1' to the left, 'file2' to the right6    - highlight the differences between the two7* :quitall - quit from both of the files (:qa)8* vimdiff -o file1.txt file2.txt 9    - open 'file1' on the top, 'file2' on the bottom10      (open one 'o'ver the other)11* vim -d -o file1.txt file2.txt 12    - same as 'vimdiff -o file1.txt file2.txt'13    - same as 'vim -do file.txt file2.txt'14* :set noscrollbind15    - the file with this command ran scrolls independently16    - when the cursor is on the other file where this command has not yet been17      run, both sides will scroll together18* ]c - jump to the next change(difference)19* [c - jump to the previous change(difference)20* (cursor on the left file) :diffget21    - :do - meaning diff obtain22    - bring the line on the file right into the file on the left23* (cursor on the left file) :diffput24    - :dp - meaning diff put25    - bring the line on the file left into the file on the right26* (cursor on the file that the change was made to) u - undo27    - notice that when you undo ':diffget' that specific difference is not28      flagged anymore!29    - rescanning needs to be done to detect it again!30* :diffupdate31    - rescan the difference
xxxxxxxxxx1591* " - comment out2* set nu3    - set number (can be toggled by entering ':set nu!' multiple times)4* set nonu5    - set nonumber6
7MAPPING8=======9
10* nmap <F3> :set nu! <CR> 11    - first 'n' stands for 'normal mode'12    - map F3 to toggle on and off the line numbers in normal mode13    - if there happen to be space after <CR>, cursor will move everytime the14      comand is executed.15* let mapleader = ','16    - map <leader> key to comma17    - unless otherwise specified, default <leader> is '\'18* nmap <leader><F3> :set rnu! <CR>19    - map <leader>F3 to toggle on and off the 'relative line numbers in normal20      mode21* imap <F3> <ESC> :set nu! <CR>i22    - first 'i' stands for 'insert mode'23    - map F3 to toggle on and off the line numbers in insert mode24        - it has to go to the 'normal mode' first and then return to 'insert25          mode' at the end26* imap <F4> <ESC> :set rnu! <CR>i27    - map F4 to toggle on and off the 'relative line numbers in insert28      mode29
30Re Assign Arrow Keys to No OPeration (in insert mode too)31~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~32You can set a key to no operation!33(no remap means the keys are not allowed to be mapped afterwards)34
35* nnoremap <Up> <Nop>36* nnoremap <Down> <Nop>37* nnoremap <Left> <Nop>38* nnoremap <Right> <Nop>39* inoremap <Up> <Nop>40* inoremap <Down> <Nop>41* inoremap <Left> <Nop>42* inoremap <Right> <Nop>43
44AUTOCORRECT DICTIONARY45======================46
47* abbr ture true48* abbr flase false49* abbr emailF kjxlee@gmail.com50
51SET DEFAULT SEARCH HIGHLIGHTING ON52==================================53
54* set hlsearch (to set off ':set nohsearch')55* set incsearch (to set off ':set noincsearch')56
57UPDATING TAB AND END OF LINE CHARACTER58======================================59
60* set listchars=tab:→\ , eol:↲61    - update the tab character to '→ unicode u2192'62    - update the end of line character to '↲ unicode u21b2'63    64FILETYPE INDENT65===============66
67* filetype indent on68    - turn on filetype indent69* autocmd Filetype perl setlocal noexpandtab tabstop=4 sw=4 sts=470    - change tab settings for perl programs71
72TEXT FOLDING73============74lines to save text folding75
76* autocmd BufWinLeave *.* mkview77* autocmd BufWinEnter *.* loadview78
79NETRW SETTING80=============81
82* nmap <F4> gh83    - map F5 to toggle on and off the line numbers in normal mode84
85* let ghregex='\(^\|\s\S\)\zs\.\S\+'86  let g:netrw_list_hide=ghregex87  - hide the dot files one startup88
89* nmap <F6> I90    - map F6 to toggle on and off the header (banner)91
92* let g:netrw_banner=093    - turn off the header at the top of the screen on startup94
95* let g:netrw liststyle= 0  96    - default view (directory name / file name)97
98* let g:netrw liststyle= 1  99    - show time and size100
101* let g:netrw liststyle= 2  102    - show listing in 2 columns103
104* let g:netrw liststyle= 3  105    - show the tree listing106
107* let g:netrw_winsize=0108    - set default window size to be always equal109
110* let g:netrw_preview=1111    - open splits to the right112
113FIX FUZZY FIND114~~~~~~~~~~~~~~115
116* autocmd FileType netrw setl bufhidden=delete (or use ':qa!')117    - per default, netrw leaves unmodified buffers open. this autocommand118      deletes netrw's buffer once it's hidden (using ':q;, for example)119* set nocompatible - limit search to your project120* set path+=** - search all subdirectories and recursively121* set wildmenu - shows multiple matches on one line122
123COLOR SHCEME124============125see 'PLUGIN' -> 'EXAMPLE' section!126
127* colorscheme pablo128    - use pablo colorscheme129
130TEXTWRAP131========132* set textwidth=80133
134[!] Note: if this command doesn't seemt to work, 135
1361. check 'formatoptions' option. it requires 't' (Vim default: tcq)1372. check if 'paste' option is switched on (to switch it off 'set nopaste')138    - when the 'paste' option is switched on (also when it was already on):139                - mapping in Insert mode and Command-line mode is disabled140                - abbreviations are disabled141                - 'autoindent' is reset142                - 'expandtab' is reset143                - 'formatoptions' is used like it is empty144                - 'revins' is reset145                - 'ruler' is reset146                - 'showmatch' is reset147                - 'smartindent' is reset148                - 'smarttab' is reset149                - 'softtabstop' is set to 0150                - 'textwidth' is set to 0151                - 'wrapmargin' is set to 0152    These options keep their value, but their effect is disabled:153                - 'cindent'154                - 'indentexpr'155                - 'lisp'1563. run ':verbose set fo' to check which file the 'formatoptions' option is157   most recently set from. 158    - remove the cause of unintentional behavior and set 'formatoptions=tcq' if159      necessary in your .vimrc file.