Você está na página 1de 4

The vi Editor - A Complete Reference

Command Syntax
Legend: [ ] optional
| choice (or)
( ) group
[count]command
[count]search_command [character|string]
["buffer_name][count]yank_command|change_command|delete_command|shift_command|put_com
mand
["buffer_name][count]yank_prefix|change_prefix|delete_prefix|shift_prefixsame_prefix
["buffer_name][count]yank_prefix|change_prefix|delete_prefix|shift_prefix[count]cursor_movemen
t

Buffers Available
Unnamed buffer
Named buffers: a to z (replace)
A to Z (append)
Numbered buffers: 1 to 9 (push down deletes)

Input Commands
A append to end of line C change to end of line
a input text after cursor c change prefix, change through
cursor movement
I input before first character on line O open new line above current line
i input text before cursor location o open new line below current line
S replace characters on current line <ctrl>? (delete) interrupt the editor
returning to
s substitute character cursor is on with command mode
following string <ctrl>{ (escape) cancel partial
command, exit
insert mode
~ change case of letter character the cursor is on

Delete Commands
D delete to end of line X delete character before the cursor
d delete prefix, delete through cursor movement x delete character cursor is on

Undo Commands
U restore current line to condition before changes
u undo last single change made to text dd deletes the line the cursor is on.

Screen Scrolling Commands


<ctrl>B scroll back one window <ctrl>F scroll forward one window
ITDC Open Systems Education - www.itdc.edu - 800.752.5448
The vi Editor - A Complete Reference
<ctrl>U scroll up 1/2 window <ctrl>Y scroll up one line, no cursor
<ctrl>D scroll down 1/2 window movement
<ctrl>E scroll down one line, no cursor
movement

Buffer Manipulation Commands


" named buffer specifier Y copy current line into a buffer
@ invoke a macro stored in a buffer movement y yank prefix, yank through cursor movement
P put text from buffer before/above cursor
p put text from buffer after/below cursor

Screen Redraw Commands


<ctrl>L clear and redraw screen
<ctrl>R redraw screen
z redraw screen with current line replaced by following character:
<return> top of screen
. middle of screen
- bottom of screen

Horizontal Line Shift/Autoindent Commands


< shift left prefix, shift through cursor movement
> shift right prefix, shift through cursor movement
<ctrl>D during insert, back-tab one shift width
<ctrl>T during insert, with autoindent, insert shiftwidth whitespace

Miscellaneous Commands
! filter lines from file through a UNIX command
& repeat last ex substitute command
J join current line and subsequent line
Q quit vi mode returning to ex mode
ZZ exits the editor, saving any changes if needed
# followed by a number, acts a function key
= reindents line for lisp
m mark cursor location with following character
. repeat the last command that changed the contents of the file
<ctrl>G print file stats
<ctrl>V during insert, "quote" next character
<ctrl>@ during insert, repeat last insert and end, 128 characters maximum
<ctrl>Q during insert, "quote"next character
<ctrl>^ return to previous position in last edited file
Cursor Movement Commands
space move cursor right one character ` move cursor to beginning of marked
line
$ move cursor to the end of the line % move cursor to matching parenthesis,
bracket or brace

ITDC Open Systems Education - www.itdc.edu - 800.752.5448


The vi Editor - A Complete Reference
( move cursor to beginning of previous
sentence G move cursor to end of file or line
) move cursor to beginning of next specified
sentence by count

{ move cursor to beginning of previous H move cursor to first character of first


paragraph line on screen
} move cursor to beginning of next h move cursor left one character
paragaraph j move cursor down one line
, repeat the last f, F, t or T search in the k move cursor up one line
opposite direction
; repeat the last f, F, t or T search in the L move cursor to first character of last
same direction line on screen
l move cursor right one character
move cursor to first character on line M move cursor to first character of middle
line on screen
^ move cursor to first non-white space
character on line N move cursor to previous occurrence of
last search pattern
+ move cursor to first non-white character
n movecursor to next occurrence of last
on next line
search pattern
- move cursor to first non-white character
on previous line T move cursor to character after previous
occurrence of following character
/ move cursor to next occurrence of
t move cursor to character before
following string
previous occurrence of following
? move cursor to previous occurrence of
character
following string
tW move cursor forward one word,
` move cursor to marked location
ignoring punctuation
[[ move cursor to previous section w move cursor to beginning of next word
]] move cursor to next section
<ctrl>H move cursor left one character
| move cursor to character position <ctrl>M move cursor to first non-white
specified by count character on next line
<ctrl>W during insert, move cursor left
B move cursor back one word ignoring one word
punctuation <ctrl>J move cursor down one line
b move cursor back one word <ctrl>N move cursor down one line
<ctrl>P move cursor up one line
<ctrl>] move cursor to word after
cursor used as a tag
E move cursor to end of next word
ignoring punctuation
e move cursor to end of next word

Options/Parameters
autoindent automatically indent next line to same indent level
autowrite automatically write file to disk when changing files
directory= specify directory in which temporary files are created
errorbells precede error messages with a bell if no standout mode
hardtabs= define spacing between hardware tab settings
lisp automatically indent lisp code properly
magic enable use of regular expression characters in searches
ITDC Open Systems Education - www.itdc.edu - 800.752.5448
The vi Editor - A Complete Reference
number show line numbers
paragraphs= specify macro names that indicate start of paragraph
readonly set the read-only flag so that changes cannot be saved

remap link a macro definition to a previous definition


scroll= set the number of lines scrolled with <ctrl>D/U
shell= specify value for SHELL environment variable
showmatch show matching parenthesis or brace during input
slowopen accommodate slow/unintelligent terminals for better speed
tags= specify file name for tag file
terse allow shorter error messages
ttytype= value from the ttytype database
window= set the number of lines scrolled with <ctrl>F/B
wrapscan automatically wrap search requests

autoprint automatically print current line after certain ex commands


beautify eliminate control characters during input
edcompatible make vi searches compatible with ex
flash flash screen instead of ringing bell on error
ignorecase ignore case of letters in regular expression searches
list display control characters and end-of-line
mesg enable terminal messages while in vi
optimize suppress automatic carriage returns on some terminals
prompt prompt for new command with "."
redraw simulate an intelligent terminal on a dumb terminal

report= set threshold for reporting number of lines changed


sections= specify macro names that indicate start of sections
shiftwidth= set spacing for shifts and between tabstops
showmode show current input mode
tabstop= define spacing when expanding tabs
term= value from the TERM environment variable
timeout specifies that escape may lead a terminal control sequence
warn send "no write" warning before a shell escape
wrapmargins= define a right margin for automatic word wrap
writeany disable checking of files before a write command

ITDC Open Systems Education - www.itdc.edu - 800.752.5448

Você também pode gostar