Hello, this is IT Dr. Ho. Today, we will look at the essential keywords and commands of vim.
vim essential commands summary
save and exit
:w save
:x Save and exit
:q quit
:q! quit without saving
move
w move to next word
W Move to next space-separated word
b go to the previous word
B Move to the previous space-separated word
e Move to the end of the current word
0 Move to the beginning of the string line
$ Move to the end of the current line
^f Page Down
^b Page Up
gg Go to the beginning of the current document
G Go to end of current document
nG move to nth line
:n move to the nth line
H Move to the beginning of the string screen
M Move to the middle of the string screen
L Move to the end of the string screen
h Left
j Down
k Up
l Right
edit
i Switch to edit mode at current location
I switch to edit mode at the beginning of the string line
a Switch to edit mode at the next character of the current position
A Switch to edit mode at the end of the string line
o Create a new line below the current line and switch to edit mode
O Create a new line above the current line and switch to edit mode
r replaces one character at the current position
R Replaces multiple letters after the current position
delete
x Deletes a single character. It works similarly to the del key.
Deletes nx n characters.
Delete the letter before X. It works similarly to BackSpace.
Deletes nX n first letters.
D Deletes from the current position to the end of the line.
dd Deletes the current line. (Cut)
ndd Deletes n lines. (Cut)
dw Deletes from the current position to the end of the word.
d0 Deletes to the beginning of the line as it is the current position.
d$ Deletes from the current position to the end of the line.
full change
:s/pattern/replacement string/flag
flag
g Replaces all patterns.
c Whenever the pattern appears, it asks whether to change it.
ex) :s/old/new/g ; Replace all the letters old with the letters new.
Search
/string Search for a specific string.
?string Searches up a specific string.
n Moves to the next found string.
Moves to the string found before N.
* Searches for the next location, such as a word in the current location.
# Search the previous position, such as a word in the current position.
undo
u undo
^r redo
to copy
v Specifies a block.
Copy the y block.
yy Copies the current line.
Copy nyy n lines.
d cut the block
dd Cut the string line.
ndd Cuts n lines.
p Paste in the current position.
Etc
:set ic Ignore case when searching
:set noic case-sensitive search
:set nu Display the line number.
. Execute the last command again.
0 Comments