How to Learn about Vim in Linux ECs, and how to use vim in linux ECs
Text Editor Vim
Vim is the most famous text/code editor on Linux systems and an enhanced version of Vi editor in earlier years, while gVim is its Windows version. Its biggest feature is its complete use of keyboard commands for editing, which makes it difficult to get started without mouse operations. However, after getting started, the various ingenious combinations of keyboard operations can greatly improve the efficiency.
Normal Mode:
Insert mode:
Command Line Mode:
1. General mode:
How to move the cursor
-H: move the cursor to the left by the left arrow key
-J: The Down Arrow (←) moves the cursor down a character
-K up arrow (←) move the cursor up to a character
-L right arrow (→) move the cursor one character to the right
-Ctrl + B flip up = page up
Ctrl + f flip down = page down
+ Move the cursor to the next line without space characters
-Move the cursor to the previous line without space characters
-0 or the beginning of the home key line
-$ Or end at the end of the key row
-G file last line
-The first line of the gg File
N + Enter move n rows
Copy, paste, and delete
X, X x delete one character backward, and X delete one character forward
-Dd: delete a row
Ndd Delete n rows
DG deletes the content from the row where the cursor is located to the last row of the file.
D $ Delete the cursor to the last character of the row
D0 deletes the cursor from the beginning of the row.
-Yy: copy a row
-Nyy: Copy n rows of yank
P, P paste
J. Combine the row where the cursor is located with the data of the next row into the same row
-U restore and undo
-Ctrl + r redo
2. insert mode:
-I, I I insert at the cursor position, and I insert at the beginning of the row where the cursor is located
O, O o Insert the next row, O Insert the last row
A, A a: insert the cursor next character, and insert the cursor at the end of the row
R, R r replace one character, R always replaces the text where the cursor is located until you Press ESC.
-[Esc] exit the editing mode and return to normal mode.
3. Command Line Mode:
Search
-Search for a word in/xxx or xxx
N next
N, go up and find
Replace
-: N1, n2s/old/new/g replace old with new from n1 to n2, and g indicates replacing all
: 1, s/old/new/g replace the old of the entire file with new: 1, "role =" presentation "> s/old/new/g replace the old of the entire file with new: 1, s/old/new/g replace the old of the entire file with new: 1, s/old/new/gc c = confirm
Y/n/a/q/l/^ E/^ Y
Y: Replace the current content.
N: do not replace
A: replace all
Q: Exit
L: Replace the current content and exit
Ctrl + E: Search backward
Ctrl + Y: forward lookup
: W Archive
: Q! Quit, exit ,!, Force
-: Wq! Save and exit. added! Force save and exit
-: X: Save and exit.
-ZZ: Save and exit
-ZQ does not save and exits.
: W [filename] Save
: R [filename]: Read another file into the file being edited.
: N1, n2 w [filename] store content from n1 to n2 as a filename File
-: Set nu displays the row number.
-: Set nonu cancels the row number.
4. vim environment settings:
/Etc/vimrc vim configuration file