PREV | UC 1471 Fundamentals of UNIX for Installers | Joho Support page |
---|
Character jumps | |
---|---|
h, j, k, l | LFarrow, DNarrow, UParrow, RTarrow |
Text jumps | |
w, W, b, B | jump forward, backward one word |
e, E | jump to end of word |
), ( | jump to beginning of next, previous sentence. |
}, { | jump to beginning of next, previous paragraph. |
]], [[ | jump to beginning of next, previous section. |
0, $ | jump to first, last position of current line |
^ | jump to first non space character of current line |
n | | jump to nth column of current line |
Line jumps | |
+, - | jump to first character of next, previous line |
H, M, L | jump to TOP, MIDDLE, LAST line of screen |
nH, nL | jump to n lines below TOP, before LAST line |
Screen jumps | |
CTRL-F, CTRL-B | jump forward, back one screen |
CTRL-D, CTRL-U | jump down, up half screen |
CTRL-E, CTRL-Y | show additional line at bottom, top of screen |
z RETURN | jump screen so cursor is at top |
z. | jump screen so that line with cursor is at the middle of the screen. |
z- | jump screen so that line with cursor is at the middle of the screen. |
Search Jumps | |
/pattern | jump to first forward occurrence of pattern. |
?pattern | jump to first backward occurrence of pattern. |
n | jump to next search in same direction. |
N | jump to Next search in opposite direction. |
/ | jump to previous pattern in forward direction. |
? | jump to previous pattern in backward direction. |
fx | jump forward to character x in current line. |
Fx | jump backward to character x in current line. |
tx | jump forward to character before x in current line. |
Tx | jump backward to character after x in current line. |
; | repeat previous search/jump in current line. |
, | repeat previous search/jump in opposite direction in current line. |
Line number jumps | |
CTRL-G | Show current line number. |
nG | Go to line number n. |
G | Go to last line in buffer. |
`` | (2 single backquotes) Go to last position before G command. |
:n | Go to line number n. |
Insert | |
---|---|
i, a | Insert text before, after cursor. |
I, A | Insert text at beginning, end of current line. |
o, O | Open new line for text below, above current line. |
R | Type over character. |
Change | |
r | Change character |
cw | Change word. |
cc | Change current line. |
C | Change from cursor to end of current line. |
s | Delete character and substitute text. |
S | Delete current line and substitute text. |
Delete | |
x | Delete character at cursor. |
X | Delete character before cursor. |
dw | Delete word. |
dd | Delete current line. |
D | Delete from cursor to end of line. |
Put | |
p, P | Put deleted/yanked text after, before cursor. |
"np | Put text from delete buffer number n after cursor. Last 9 deletions are available. |
"aP | Put text from buffer a before cursor. |
Yank | |
yw | Yank (copy) word. |
yy | Yank (copy) current line. |
"ayy | Yank current line into named buffer a. |
ex commands | |
:d | Delete line(s). |
:m | Move line(s). |
:co | Copy line(s). |
:.,$d | Delete from current line through end of buffer. |
a,bm. | Move lines from line numbers a through b after the current line. |
.,/pattern/co$ | Copy from the current line through first line containing pattern to the end of file. |
vi file | Invoke vi editor on file. |
vi file1 file2 | Invoke vi editor on file1, then on file2. |
view file | Invoke vi editor in read only mode on file. |
vi -R file | Invoke vi editor in read only mode on file. |
vi -r file | Recover file and recent edits after system crash. |
vi + file | Open file with cursor at last line. |
vi +n file | Open file with cursor at line number n. |
vi +/pattern file | Open file with cursor at first occurrence of pattern. |
ex file | Invoke vi in ex mode on file. |
ZZ | Write (save) and quit current file. |
:x | Write (save) and quit current file. |
:wq | Write (save) and quit current file. |
:w | Write (save) current file. |
:w! | Write (save) current file, overriding protection. |
:a,bw newfile | Write lines a through b as newfile. |
:a,bw>> file | Write lines a through b appended to file. |
:w %.new | Write current buffer named file to file.new |
:q | Quit file. |
:q! | Quit file, overriding protection. |
:Q | Quit vi and invoke ex. |
:e file2 | Edit file2 without leaving vi. |
:n | Edit next file. |
:e! | Return to version of current file at time of last write (save). |
:e# | Edit alternate file. |
% | Print (display) current file name. |
# | Print (display) alternate file name. |
vi commands | |
---|---|
. | Repeat the last command. |
u, U | Undo last command, commands on current line. |
J | Join 2 lines. |
CTRL-L, CTRL-R | Redraw the screen. |
ex commands | |
: | Invoke ex mode from vi editor. |
:vi | Invoke vi mode from ex editor. |
:sh | Invoke shell. |
CTRL-D | Return to editor from shell. |
:! shell command | Execute shell command. |
:r filename | Read contents of filename onto end off current buffer. |
:r! shell command | Read output from shell command onto end of current buffer. |
Mark | |
mx | Mark current position as x. |
`x | Move cursor to x. |
`` | (2 backquotes) Return to previous mark or context after a move. |
'x | (1 single quote) Move to beginning of line containing mark x. |
'' | (2 single quotes) Move to beginning of line containing previous mark. |
Abbreviations | |
:map x sequence | Define the single keystroke x as a sequence of editing commands. |
:unmap x | Disable the map x. |
:ab abbr phrase | Abbreviate phrase as abbr; when abbr is typed in insert mode, it expands to full words or phrases. |
:unab abbr | Disable abbreviation. |
Environment | |
:set option | Activate option. |
:set option=value | Assign value to option. |
:set nooption | Deactivate option |
:set | Display options set by user. |
:set all | Display list of all current options, both default options and options set by the user. |
:set option? | Display value of option. |
PREV | UC 1471 Fundamentals of UNIX for Installers | NEXT |
---|