Nothing Special   »   [go: up one dir, main page]

VI Editor

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

General Startup To use vi: vi filename To exit vi and save changes: ZZ or :wq To exit vi without saving changes: :q!

To enter vi command mode: [esc]

or punctuation mark B previous word, move to the beginning of the

Inserting
r next replace character under cursor with

ignores punctuation

character typed R hit keep replacing character until [esc] is

Counts
e A number preceding any vi command tells vi to repeat that command that many times. E H M L h j k l [return] line $ 0 the current line ^ on the current line w word or ( does not work with VT100 type punctuation mark W b previous word move past the next space move to the beginning of the terminals words, or characters ^L redraw screen P ( does not work with Televideo terminals ) p bring back after cursor bring back before cursor move to the beginning of the next move cursor to first nonblank column last column on the current line screen move cursor to the first column on ^F ^B ^D ^U ^R move forward one screen put by move backward one line the p(put) command. Precede with a count for move forward one half screen multiple lines. move backward one half screen yy (yank)'copies' line which may then be move left (backspace) move down move up move right (spacebar) move to the beginning of the next screen db zmove current line to the bottom of delete word before cursor end of next word, ignoring punctuation i move cursor to the top of the screen a append after cursor append at end of line open line above cursor and enter append move cursor to the middle of the screen A move cursor to the bottom of the screen O mode insert before cursor end of next word or punctuation mark

Cursor Movement

Screen Movement
G xG z+ z move to the last line in the file

Deleting

x move to line x dd move current line to top of screen dw move current line to the middle of

delete character under cursor delete line under cursor delete word under cursor

Copying Code

Put Command
redraw screen brings back previous deletion or yank of lines,

% to its mate

if at one parenthesis, will jump

SHELL ESCAPE
executes 'cmd' as a shell command.

Find Commands
mx x ? / f finds a word going backwards finds a word going forwards 'x finds a character on the line under the find line marked with character x mark current line with character

:!'cmd'

NOTE: Marks are internal and not written to


cursor going forward F finds a character on the line under the cursor going backwards issued t going forward and stop one character before it To exit: press[return] or [esc] T going find a character on the current line find a character on the current line upon entering line mode. To enter: type ':' the file.

Line Editor Mode


Any commands form the line editor ex can be

ex Commands
backward and stop one character before it ; repeat last f, F, t, T For a complete list consult the

UNIX Programmer's Manual READING FILES


copies (reads) filename after cursor in file currently editing :r filename

Miscellaneous Commands
. u U xp inserts after repeat last command undoes last command issued undoes all commands on one line deletes first character and

WRITE FILE
:w saves the current file without

second (swap) J line join current line with the next

quitting

MOVING
:# move to line # move to last line of file

^G

display current line number :$

You might also like