|
COMMAND
|
PURPOSE
|
|
:x
|
Quits vi,writing modified file.
|
|
:wq
|
Quits vi,writing modified file. It
behaves exactly like :x.
|
|
:q
|
Quit (
or exit) vi
|
|
:q!
|
Quits vi
without saving the latest changes.
|
|
ZZ
|
saves
and exits. This is known as last command.
|
|
:w
|
Writes
the modified file and remains in the command mode.
|
|
h
|
Move
cursor left one character.
|
|
j
|
Move
cursor down one line.
|
|
k
|
Move
cursor up one line.
|
|
i
|
Moves
cursor right one character.
|
|
0(zero)
|
Move
cursor to start of current line(the one with the cursor)
|
|
$
|
Move
cursor to end of current line.
|
|
W
|
Move
cursor to beginning of next word.
|
|
b
|
Moves
cursor back to beginning of preceding
word .
|
|
:0 or 1G
|
Moves
cursor to first line in the file.
|
|
:n or nG
|
Moves
cursor to line n.
|
|
:$ or G
|
Moves
cursor to last line in file.
|
|
^f
|
Moves
forward one screen.
|
|
^b
|
Moves
backward one screen.
|
|
^d
|
Moves
down (forward) one half screen.
|
|
^u
|
Moves up
(back) one half screen.
|
|
u
|
UNDO
WHATEVER YOU JUST DID; a simple toggle .
|
|
ctrl r
|
Redo
|
|
i
|
Insert
text before cursor , until you press <Esc>
|
|
a
|
Appends
text after cursor , until you press <Esc>
|
|
o
|
Open and
puts text in a new line below current line, until you press <Esc>
|
|
O
|
Opens
and puts text in a new line above current line , until you press <Esc>
|
|
r
|
Replaces
single character under cursor.
|
|
R
|
Replaces
character, starting with current cursor position , until you press<Esc>
|
|
x
|
Deletes
single character under cursor.
|
|
dd
|
Delete
entire current line
|
|
yy
|
copies (yank,
cut) the current line into the buffer.
|
|
p
|
puts
(paste) the line(s) in the buffer into the text after the current line.
|
|
:r file name
|
Reads
file named filename and insert after current line (the line with cursor)
|
|
:w
|
Writes
current contents to file.
|
|
:w newfile
|
Writes
current contents to a new file named newfile .
|
|
:w! prevfile
|
Writes
current contents over a pre-existing file named pervfile.
|
|
/string
|
Searches
forward for occurrence of string in text.
|
|
?string
|
Searches
backward for occurance of string in text.
|
|
n
|
Moves to
next occurrence of search string
|
|
N
|
Moves to
next occurrence of search string in opposite direction.
|
|
.(dot)
|
Any
single character except newline.
|
|
*
|
Zero or
more occurrence of any character.
|
|
[.....]
|
Any
single character specified in the set.
|
|
[! .]
|
Any
single character not specified in the set.
|
|
^
|
Anchor-beginning
of the line.
|
|
$
|
Anchor-end
of line.
|
|
[A-Z]
|
The SET
from capital A to capital z.
|
|
[a-z]
|
The SET
from lowercase a to lowercase z.
|
|
[0-9]
|
the SET
from from 0 to 9(All numerals).
|
|
[0-9 A-Z]
|
The SET
contains all capital letters and digits and a space.
|
|
[A-Z][a-zA-Z]
|
In the
second character position , the SET containing all letters
|
|
/Hello/
|
Matches
if the line containing the value Hello.
|
|
/^TEST$/
|
Matches
if the line contains TEST by itself.
|
|
/^[a-zA-Z]/
|
Matches
if the line starts with any letter.
|
|
/^[a-z]*/
|
Matches
if the first character of the line is a-z and there is atleast one more of
any character following it.
|
|
/2134$/
|
Matches
if line ends with 2134.
|
|
/[0-9]*
|
Matches
if there are zero or more numbers in the line.
|
|
/^[!#]/
|
Matches
if the first character is not a # in the line.
|
|
:.=
|
Returns
line number of current line at bottom of screen.
|
|
:=
|
Return
the total number of lines at bottom of screen.
|
|
^g
|
Provides
the current line number , along with the total number of lines, in the file
at the bottom of the screen.
|
Jun 3, 2017
Unix VI Commands
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment