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 37 changed 3 lines |
|:w|save file but don't quit |
|:w newname|save file to new file named newname |
|:r filename|read file filename into the current buffer after the current line |
|: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 41 changed one line |
!!Cursor movement |
!!Cursor movement (in addition to possible cursor keys) |
At line 43 changed one line |
(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 51 changed one line |
|0| beginning of line |
|0| beginning of line (zero) |
At line 53 removed 2 lines |
|^f| forward a page |
|^b| back a page |
At line 57 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 60 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 64 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 67 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 87 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 one line |
|:e!|undo all changes since last save |
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}}} |
|
|
|
|
|
|