created on 20220624, edited 20220628 author: mighty25 title: vi_tips.txt movement -------------------------------------------- H - upper left corner M - middle line L - lower left corner G - goto last line nG - goto line n 0 - beginning of line $ - end of line d - scroll down half a screen u - scroll up half a screen f - page forward b - page back j - up k - down h - left l - right ^ or 0 - beginning of line $ - end of line :n - goto line n copy to general buffer -------------------------------------------- yy or Y - yank line into the buffer nyy or nY - yank n lines into the buffer ~znyy - yank n lines into buffer z yw - yank word into buffer insert from buffer -------------------------------------------- p - insert from buffer after the cursor P - insert from buffer before the cursor ~ap - insert from buffer a after the cursor J - join lines delete -------------------------------------------- dd - delete a line to buffer ndd - delete n lines to the buffer D - delete to the end of the line x - delete a char dw - delete word to buffer ndw - delete n words to the buffer d) - delete to end of sentence into buffer ~andd - delete n lines to buffer a ~Andd - delete n lines and append then to buffer a edit ------------------------------------------- i - start edit mode O - open edit in the above o - open edit in line below search ------------------------------------------- /pattern - search forward ?pattern - search backward esq r - enter replace mode :s/old/new/g - s & r all occurrences of old with new on the line :1,$ s/old/new/g - s & r all occurrences of old w new between lines 1 and eof file ------------------------------------------- :r - insert file after line :w or :w filename - write to filename :q! - quit without saving :e new - edit new file :20,40w new - write lines 20 thru 40 into file new :wq or :ZZ - write file and exit :sh - execute a shell command vi -R filename - starts vi in readonly :n - move to next file in list given to vi at launch :p - move to prev file in list given to vi at launch :e filename - edit a new file without leaving vi -------------------------------------------- parameters -------------------------------------------- :set list - show invisible characters :set nolist - don't show invisible characters :set number - show line numbers :set nonumber - don't show line numbers :set autoindent - indent after a cr :set noautoindent - turn off autoindent :set showmatch - show matching parentheses as typed :set noshowmatch - turn off showmatch :set showmode - display mode on last line :set noshowmode - turn off showmode :set all = show all parameters --------------------------------------------