| At line 3 changed one line |
| The VI editor has three main modes: |
| VI is the standard visual text editor available on all Unix, Linux, BSD, and other Unix-like computer systems. It also comes with Mac OS/X, and is available for Windows. |
| At line 5 added 2 lines |
| The VI editor has three modes: |
|
| At line 6 changed one line |
| * edit mode (insert or overtype text) |
| * edit mode (insert or over-type text) |
| At line 15 changed one line |
| nothing so if you are confused just hit the Esc key and you'll know |
| nothing. So if you are confused, just hit the Esc key and you'll know |
| At line 28 changed one line |
| Command are case sensitive so thet j and J are different commands. |
| Commands are case sensitive so that j and J are different commands. |
| At line 32 changed one line |
| !!Saving and exiting |
| !!Saving, exiting, and file commands |
| At line 36 changed 2 lines |
| |:q!|quit without saving (even if file had ben changed - lose changes) |
| |:w|save file but don't quit |
| |:q!|quit without saving (even if file had been changed - lose changes) |
| |:w|write (save) file but don't quit |
| |:w newname|write (save) file to new file named newname |
| |:wq|write (save) and quit |
| |:r filename|read (insert) file filename into the current buffer after the current line |
| At line 44 added one line |
| !!Cursor movement (in addition to possible cursor keys) |
| At line 40 changed 3 lines |
| !!Cursor movement |
|
| (The letters hjkl on the keyboard form a sort of arrow keys)\\ |
| (The letters hjkl on the keyboard form a set of arrow keys)\\ |
| At line 52 added 5 lines |
| See Searching below. |
|
| |return|first character of next line |
| |+|first character of next line |
| |-|first character on previous line |
| At line 50 changed one line |
| |0| beginning of line |
| |0| beginning of line (zero) |
| At line 52 removed 2 lines |
| |^f| forward a page |
| |^b| back a page |
| At line 56 changed one line |
| |15G| goto line 15 (basically you can preceed G with any line number) |
| |15G| goto line 15 (basically you can precede G with any line number) |
| |H|home - top of screen |
| |M|middle of screen |
| |L|last line on screen |
| At line 68 added one line |
| !!Screen movement (scrolling) |
| At line 59 changed one line |
| !!Text editing (all text entry except r ends by hitting the Esc key) |
| |^f| forward a page |
| |^b| back a page |
| |z return|scroll current line to top-of-screen |
| |z.|scroll current line to middle-of-screen |
| |z-|scroll current line to bottom-of-screen |
| At line 76 added 3 lines |
|
| !!Text editing (Edit Mode - all text entry except "r" ends by hitting the Esc key) |
|
| At line 63 changed 2 lines |
| |r| replace a single character |
| |R| replace or overtype (doesn't require Esc key to end) |
| |r| replace a single character (doesn't require Esc key to end) |
| |R| replace or over-type |
| At line 66 changed 2 lines |
| |o| add text after the current line (open a line) |
| |O| add text before the current line |
| |o| add text after the current line (open a line) (oh) |
| |O| add text before the current line (capitol oh) |
| At line 69 changed one line |
| |S| replace the cuuent line with entered text |
| |S| replace the current line with entered text |
| At line 93 added one line |
| |X| delete previous character |
| At line 80 changed one line |
| (Remeber that any command can be preceeded by a number so things line |
| (Remember that any command can be preceded by a number so things line |
| At line 86 changed 2 lines |
| |/xxxxx<return-key>| search forward for xxxxx |
| |?xxxxx<return-key>| search backwards for xxxxx |
| |/xxxxx<return-key>| search forward for regular expression xxxxx |
| |?xxxxx<return-key>| search backwards for regular expression xxxxx |
| At line 109 added one line |
| Vi's regular expression syntax corresponds to grep's basic regular expression syntax. See [grep] |
| At line 111 added one line |
|
| At line 128 added 2 lines |
| |:e!|undo all changes since last save |
| |.| repeat last text-changing command |
| At line 131 added 5 lines |
| |:set autoindent|turn on auto-indent mode |
| |:set noautoindent|turn off auto-indent mode |
| |^L|redraw screen |
| |!cmd|run cmd in a separate shell |
| |r!cmd|run cmd in a separate shell and insert result into buffer |
| At line 137 added one line |
|
| At line 153 changed 2 lines |
| # Use any of the delete or copy (yank) commands with or wothout |
| named variables. |
| # Use any of the delete or copy (yank) commands with or without named variables. |
| At line 160 changed one line |
| !!Search and Replace |
| !!Search and Replace (Substitute) |
| At line 170 changed 5 lines |
| |:s/OLD/NEW/| replace the first occurance of OLD with NEW on current line |
| |:s/OLD/NEW/g| replace all occurances of OLD with NEW on current line |
| |:%s/OLD/NEW/g| replace all occurances of OLD with NEW on all lines |
| |:50,100s/OLD/NEW/g| replace all occurances of OLD with NEW on lines 50-100 |
| |:%s/OLD/NEW/gc| replace all occurances of OLD with NEW on all lines with confirmations |
| |:s/OLD/NEW/| substitute the first occurrence of OLD with NEW on current line |
| |:s/OLD/NEW/g| substitute all occurrences of OLD with NEW on current line |
| |:%s/OLD/NEW/g| substitute all occurrences of OLD with NEW on all lines |
| |:50,100s/OLD/NEW/g| substitute all occurrences of OLD with NEW on lines 50-100 |
| |:%s/OLD/NEW/gc| substitute all occurrences of OLD with NEW on all lines with confirmations |
| At line 204 added one line |
| !!Multiple Files |
| At line 206 added one line |
| Vi can edit multiple files. When initially calling up VI, it may be called with multiple file names on the command line. VI supports the following commands to handle multiple files: |
| At line 208 added 4 lines |
| |:n|next file is switched to |
| |:N|previous file is switched to |
| |:w|save the current file |
| |:e newfile|edit file named newfile |
| At line 214 added 61 lines |
|
| ---------------------------------------------------------------------- |
|
| !!!VIM Commands |
|
| VIM, a popular version of VI, has the following additional commands available to it: |
|
| !!Buffers |
|
| |:ls|list buffers |
| |:bn|next buffer |
| |:bp|previous buffer |
| |:bN|switch to buffer named N (with tab completion) |
|
|
| !!Windows |
|
| Window commands begin with ^w. The second letter can be either the letter by itself, or at can be used as a control letter (so you don't have to release the control key if you don't want to.) |
|
| !Opening and closing windows |
|
| |^ws|split window horizontally |
| |^wv|split window vertically |
| |^wn|edit a new file in an additional / new window |
| |^wc|close the window you are in |
| |^wo|close all other windows |
|
| ! Moving cursor to different windows |
|
| Use ^w followed by h, j, k, l, up arrow, down, left, or right to move the cursor to the indicated window. |
|
| ! Controlling the window size |
|
| |^w=|Make all windows equal size |
| |^w-|Make current window smaller (also takes prefix argument) |
| |^w+|Make current window larger (also takes prefix argument) |
|
|
| !! Editing remote files |
|
| vim scp://username@host.com/path/to/file |
|
| :e scp://username@host.com/path/to/file |
|
| !! VIM Startup |
|
| When vim starts up, it reads the file ~/.vimrc |
|
| You can put configuration commands in that file. |
|
| ! Stopping the colors |
|
| Put the following in .vimrc |
|
| {{{syntax off}}} |
|
|
|
|
|
|