vi - editor Command Sheet Prof. Michael P. Harris, CCNA, CCAI

advertisement
vi - editor Command Sheet
:
:q
:q!
:w
:wq
ZZ
:wq!
:!
:!ls
:!rm filename
:r filename
Prof. Michael P. Harris, CCNA, CCAI
ITSC 1358 - UNIX System Admin
Command (last line) mode.
Quit.
Quit aborting all changes.
Write changes to file.
Write changes and Quit.
write changes and quit.
Write changes and Quit (use when file is write protected).
followed by a UNIX command, to execute that command.
to get a listing of your directory.
remove (delete) the file filename.
retrieves the file filename, and inserts it into the current
file following the cursor position.
To move the cursor use the arrow keys, or press the H, J, K, L keys on the home row -right side:
<h
^
k
l>
e.g. h (left)
j (down) k (up)
l (right)
j
v
^G
G
nG
0
$
w
W
:1
:5
<Ctrl-G> Show current line number and status.
Go to end of document.
Go to line n.
Go to beginning of line. (Zero)
Go to end of line. (Dollar Sign)
Go to next word.
Go to next Word ignoring special characters.
Go to line 1.
Go to line 5.
<Esc>
a
A
i
I
o
O
r
R
return to Edit mode: e.g. Exit append, insert, or overwrite modes.
append mode beginning after current cursor position.
Append mode after end-of-line.
insert mode beginning before current cursor position.
Insert mode at beginning of line.
open new line below curser (insert mode).
Open new line above curser (insert mode).
x
dd
5dd
dw
dW
d$
D
delete
delete
delete
delete
delete
delete
Delete
yy
5yy
"yank" (copy) current line into buffer (clipboard).
"yank" (copy) five lines into buffer.
p
P
"put" (paste) buffer onto line below cursor.
"Put" (paste) buffer onto line above cursor.
replace single character.
over-wRite mode.
(cut)
(cut)
(cut)
(cut)
(cut)
(cut)
(cut)
single character into buffer (clipboard).
current line into buffer (clipboard).
next 5 lines into buffer (clipboard).
word beginning at cursor into buffer.
Word beginning at cursor ignoring special characters.
to the end-of-line.
from cursor to end-of-line into buffer.
Page 1 of 4
vi editor – Command Sheet
cw
cW
change current word beginning at cursor.
change current Word ignoring special characters.
u
U
.
undo last change.
Undo changes on current line.
repeat the last command.
:%s/abc/DEF/
:%s/abc/DEF/g
:1,5s/abc/DEF/
:6,.s/abc/DEF/
:6,$s/abc/DEF/
:%g/abc/d
:%v/abc/d
substitute letters "abc" with "DEF".
global substitution: e.g. multiple occurrences on a given line.
substitute letters "abc" with "DEF" lines 1 thru 5 only.
substitute letters "abc" with "DEF" line 6 thru current line.
substitute letters "abc" with "DEF" line 6 thru end-of-file.
delete all lines globally containing characters "abc".
delete all lines except those containing the characters "abc".
/abc
/^abc
Search for lines containing the string "abc".
Search for lines that begin with "abc".
vi editor – Command Sheet
Alphabetical quick command list:
a
b
c
d
dd
e
f
h
i
j
k
l
m
n
o
p
r
s
t
u
w
x
y
yy
z
append after cursor
move back to previous word or count words
change to motion
delete to motion into buffer (clipboard)
delete current or count line(s) into buffer (clipboard)
move to end of current word
character in-line forward search
move left by columns
--> H J K L on the keyboard
- <Left arrow>
insert before cursor
move down by lines
--> H J K L on the keyboard
- <Down arrow>
move up by lines
--> H J K L on the keyboard
- <Up arrow>
move right by columns
--> H J K L on the keyboard
- <Right arrow>
set mark
next -repeat last search
open/append new line below current line
put/Paste after cursor from buffer (clipboard)
replace current or count character(s) -with next character(s) typed
substitute count character(s)
before character in-line forward search
undo last change
move to next word or count words
Delete current or count character(s) into buffer (clipboard) - <Delete> key
yank/Copy text to motion into buffer (clipboard)
yank/Copy current or count line(s) into buffer (clipboard)
redraw/refresh screen
A
B
C
D
E
F
G
H
I
J
L
M
N
O
P
Q
R
S
T
U
W
X
Y
ZZ
Append to end-of-line ($a)
move Back to previous big-word
Change to end-of-line
Delete to end-of-line into buffer (clipboard)
move to End of big-word
character in-line backward search
Go to line number -or last line in the file
move to the High/first line on the screen
Insert at beginning of current line (^i)
Join lines
move to the Low/last line on the screen
move to the Middle/center line on the screen
Next -reverse last search
Open/insert new line above current line
Put/Paste before cursor from buffer (clipboard)
switch to ex command mode
Replace count character(s)
Substitute count line(s)
before current character in-line backward search
Undo/Restore the current line
move to next big-Word
Delete character(s) before cursor into buffer (clipboard) - <Backspace> key
Yank/Copy count line(s) into buffer (clipboard)
save file and exit (:wq)
vi editor – Command Sheet
^A
^B
^C
^D
^E
^F
^G
^H
^J
^L
^M
^N
^P
^R
^T
^U
^V
^W
^Y
^Z
search forward for cursor word
scroll screen Back
- <Page Up> key
Cancel/interrupt an operation -e.g. read, write, search, ...
scroll half screen Down (setting count)
scroll down by lines
scroll screen Forward
- <Page Down> key
show file status and current line number
move left by character(s)
move down by line(s)
redraw screen
Move down by line(s) (to first non-blank line)
move down to Next line
move up to Previous line
Redraw screen
Tag pop
scroll half screen Up (set count)
insert a literal character
move to next screen
scroll page up by line(s)
suspend editor
^[
^\
^]
^^
<Escape> leave Input mode, return to Edit mode
switch to ex mode
tag push cursor word
switch to previous file
0
$
|
^
_
+
#
(
)
{
}
[[
]]
`
'
%
<
>
!
<Space> move right to next or count character(s)
move to first character (zero)
move to last character (dollar sign)
move to column position (pipe)
move to first non-blank (carrot)
move to first non-blank (underscore)
move down to next or count line(s) -to first non-blank (plus)
move up to prior or count line(s)
-to first non-blank (minus)
number -increment/decrement
move back sentence
move forward sentence
move back paragraph
move forward paragraph
move back section
move forward section
move to mark (from m command)
move to mark (to first non-blank)
move to match
shift lines left to motion
shift lines right to motion
filter through command(s) to motion
.
/
?
;
&
,
~
repeat the last command
search forward
search backward
repeat last F, f, T or t search
repeat substitution
reverse last F, f, T or t search
reverse case
:! execute Unix command
@ execute command(s) in buffer (clipboard)
Download