I. Substitution and revocation of characters (undo action) 1. Replace and revoke (undo) command
Both the Replace and undo commands are for normal mode operations
Command |
Description |
r +< to replace letters > |
Replace the letter that contains the cursor with the specified letter |
R |
Continuous replacement until you press theEsc |
cc |
Replace the entire row, which deletes the row of the cursor and enters insert mode |
cw |
Replace a word, delete a word, and enter insert mode |
C Uppercase |
Replace cursor later to end of line |
~ |
Reverses the case of a cursor in the same letter |
u N |
Undo One or N operations |
U Uppercase |
Undo all changes to the current line |
Ctrl+r |
Redo, that is, undo undo operation |
To open a file for editing:
$ vim practice_2# 输入以下文本www.shiyanlou.com
Then do the following:
- Input
11G
, jump to 11 lines
- Enter FA to jump to the first
a
character
- Input
r
, and the input b,a character is replaced by the B character (practical)
- Enter a
R
replacement character, enter a new string, press ESC to return to normal mode (useful)
- Enter
cc
replace whole line character, enter new string, press ESC to return to normal mode after entering
- Enter
cw
replace one English word (word), press ESC to return to normal mode (useful)
- Input
~
, the case of the character in which the rollover cursor is located
- The input is
C
replaced with the end of the line, that is, the word will be replaced after the cursor is in place, press ESC to return to normal mode
- Enter
u
undo Last action
Second, fast indent 1. Use commands to quickly adjust indent operations
This section learns how to indent quickly in vim and indent operations are effective in normal mode
Open a file for editing
$ vim protocols
- Normal mode input
15G
, jump to 15 lines
- Input entire line in normal mode
>>
indent right (used to format code super cool)
- Enter the entire line in normal mode to the
<<
left fallback
- Normal mode enter
:
command line mode to shiftwidth
set values to control the number of characters for indentation and fallback
2.shiftwidth command
shiftwidth
The command refers >>
to the indentation generated by the previous command (which can be abbreviated sw
). Enter :
command line mode to set values in normal mode to control the number of characters in shiftwidth
indentation and fallback get current setpoint
:set shiftwidth?
Set indent to 10 characters
:set shiftwidth=10
Enter ESC
back into normal mode and try again to >>
see if the indent changes
3. Adjust the text position
Command line mode enter :ce
(center) command to center the contents of the bank
:ce
Command line mode enter :ri
(right) command to make our text
:ri
Command line Mode enter: le
(left) command to leave the contents of the bank
:le
Third, find 1. Quick Find
Enter Normal mode /
and then type the string you want to find and press ENTER to find it. ?
is the same as the /
function, but ?
looks up and /
down. After entering the lookup, the input n
and N
can continue to find n
the expression to continue the lookup, N
reverse Lookup
2. Quick Find Exercises
Use VIM to open a file for editing
$ vim protocols
- Normal mode input
/icmp
find string ICMP
- Normal mode Enter to
n
find the next ICMP
- Normal mode input
?tcp
up lookup string TCP
- Normal mode input
N
to find the last occurrence of TCP
3. Advanced Search
- Enter
\*
a word in normal mode to find where the cursor is located
- Normal mode input
\#
Ibid, but \*
forward (up) to find, #则是向后 (bottom) find
- Normal mode
g\*
\*
, but partially matches the word
- Normal mode
g\#
\#
, but partially matches the word
Search for n
The above, N
continue to find command can still be used
Iv. Summary
This section learns about substitutions, undo actions, and quick lookups, where replacement and quick find within a document is useful.
(Big Data Engineer Learning Path) Step two vim editor----find and replace