Common commands of the text editor vi and Common commands of the vi in linux
I. Paging
Ctrl + u flip up half page
Ctrl + f Turn up one page
Ctrl + d flip down half page
Ctrl + B flip down one page
Ii. move the cursor
0: move the cursor to the beginning of the current row
$: Move the cursor to the end of the current row
Iii. Common insert and delete commands
I: insert in front of the current cursor, move the text behind the cursor to the back
Dd: Delete the row where the cursor is located.
Yy: copy the content of the current row to the clipboard.
P: paste the content in the clipboard after the current cursor position
P: paste the content in the clipboard before the current cursor position
S: Starting from the current cursor position, replace the specified number of characters with the input text
S: delete a specified number of rows and replace them with the input text
Do: Delete to the beginning of a row
D $: Delete to the end of the row
Iv. vi search, save, and exit
Press u to cancel the last operation. You can perform the operation multiple times, similar to canceling the operation.
Press U to cancel all edits on the current row. : W -- save the current file
: Wq -- save disk to exit (same as command: x)
: Q -- exit directly. If modified, a message indicating whether to save the modification is displayed.
: Q! -- Exit directly without saving
5. Open a new file or read other file content
In the current vi Editor, execute the last line command in the form of ": e new file" to edit the new file.
In the current vi Editor, execute the last line command in the form of ": r other files" to read the contents of other files and copy them to the position of the current cursor.
In the current vi Editor, Run ": r! Command "form of Moxing mode, you can paste the output of other commands to the position of the text file cursor.
Run the "set number" command in the last line mode to display the row number. Run "set nonu" to undisplay the row number.
Vi. vim editor's useful parameters
Vim-o file1 file2; the two files are opened at the same time and displayed up and down. use ctrl + w to switch files.
Vim-O file1 file2; the two files are opened at the same time and displayed on the left and right. use ctrl + ww to switch the file.