리눅스 vi 명령어 모음(linux vi command)
1. Basic command
1-1 Create a new file with vi
vi filename
1-2 To exit
:q
or
:q!
1-3 command mode & input mode
- Command mode
- vi initial state
- not echo the command back on the screen
- input mode
- able to edit file contents(data)
- leave with “ESC”
2. Saving & exiting details
2-1 Saving
- write current file
:w
- write with the filename
:w filename
2-2 Exiting
- quit vi after saving
:q
* If not saved, error pop
- quit vi without saving
:q!
2-3 Exiting with Saving
- write and quit
:wq
or
ZZ
saving by new name
:wq filename
3. Moving and inserting cursor
3-1 Inserting cursor
- insert before cursor(i)
“i + contents”.
ihi
- Insert at Beginning of line(I)
“I + contents”.
Ihi
- append after cursor(a)
“a + contents”.
ahi
- Append after cursor(A)
“A + contents”.
Ahi
- add new line after cursor(o)
o
- add new line befor cursor(O)
o
3-2 Moving cursor
moving single step
- beginning of the current line
^
(not ctrl)
or
0
moving by word
- one word forward
w
- one word backward
b
- end of next word
e
moving by screen
- screen top(head)
H
- screen middle
M
- screen bottom
L
moving by line
- Go to line #
#G
or
:#
- Go to last line
:$
or
G
- end of the current line
$
- beginnig of the previous line
-
- beginning of the next line
+
- move forward # lines
#+
- move backward # lines
#+
4. Undo & delete command
4-1 undo
- undo last command
u
- Undo all command(from open the vi)
U
4-2 delete
- delete single word
x
- delete # words
#x
- delete single word
dw
- delete # words
#dw
- delete current line
dd
- delete current # line
#dd
- Delete cursor ~ line end
D
Leave a comment