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 that 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 37 changed one line |
|:w|save file but don't quit |
|: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 preced 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 over-type (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 93 added one line |
|X| delete previous character |
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 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}}} |
|
|
|
|
|
|