Functions of the text editor: 1. create or modify a text file 2. maintain the classification of various configuration file text editors in linux: line editor and full screen editor, character interface editor and graphical interface editor the most common text editor in linux: vi: the default text editor vim: enhanced version of the vi editor in unix-like systems.
Functions of the text editor: 1: create or modify a text file
2. maintain various configuration files in linux
Text editor category: Line editor and full screen editor, character interface editor and graphic interface editor
The most common text editor in linux: Vi: the default text editor in unix-like systems
Vim: enhanced version of vi editor, also known as vi
Three working modes of the vi editor: Command mode, input mode, and last line mode
Enter input mode: Enter the insert status at the current cursor: I
Insert status after the current cursor:
Move the cursor to the end of the current row and enter the insert Status:
Insert a new row under the current row. move the cursor to the beginning of the new row to enter the insert status: o
Insert a new row above the current row, move the cursor to the beginning of the new row to enter the insert status: O
Delete the character from the cursor to the end of the word and enter the insert status: cw
Delete the character from the cursor to the end of the line and enter the insert Status: c $
Delete the character from the cursor to the beginning of the line and enter the insert Status: c ^
Go to the vi editing environment: Open the file and place the cursor at the beginning of the first line: vi file name
Open the file and place the cursor at the beginning of line n: vi + n file name
Open the file and place the cursor at the beginning of the last line: vi + file name
Open the file and place the cursor at the first string matching the character:
Vi +/character file name
Use vi to open multiple files: Multiple directory files (up and down) can be displayed simultaneously: vi-o
Multiple directory files (left and right) can be displayed simultaneously: vi-O
Switch between multiple directory files: ctrl + w
Vi multi-file Operation Commands: Display multi-file information: args
Switch the file backward: next
Forward switch File: prev
Locate the first file: first
Locate the final File: last
Quickly switch to the file before switching in the editor: ctrl + ^
A system crash occurred when editing with vi last time. Restore File: vi-r file name
Move cursor: Backward or k: up backward or j: Down
Direction or h: Left → or l: right
Flip: Page Down or ctrl + F: scroll Down the entire Page
Page Up or ctrl + B; move Up a whole Page
Ctrl + f: ctrl + B on the entire forward page; flip down the entire page
Ctrl + u: half page up ctrl + d: half page down
Fast intra-row jump: Jump to the beginning of the line: Home key, "^", or number "0"
Jump to the End of a row: End or $
Jump to the first letter of the next word: w
Jump to the first letter of the previous word: B
Jump to the end of the last word: e
Fast jump between lines: Jump to the first line of the File: 1 GB or gg
Jump to the end of the File: G
Jump to line # in the file: # G
Row number display: Display the row number in the editor: set nu
Cancel the line number display in the editor: setnonu
Delete:Delete a single character at the cursor: x or Del
Delete the row where the current cursor is located: dd
Delete the # Line content starting from the cursor: # dd
Delete all characters from the current cursor to the beginning of the line: d ^
Delete all characters from the current cursor to the end of the line: d $
Delete all characters from the current character to the end of the word (including spaces at the end of the word): dw
Delete all characters from the current character to the end of the word (excluding spaces at the end of the word): de
Delete the line break from the row where the cursor is located to the end of the line, which is equivalent to merging the content of the current row and the next row: J
Copy: Copy the entire row of the current row: yy
Copy the line content starting from the cursor: # yy
Copy the content from the current cursor to the end of the line: y $
Copy the content from the current cursor to the beginning of the line: y ^
Copy the content of the current cursor to the end of the word: yw
Paste: Paste it before the cursor position: p
Paste to the cursor position: P
Search for strings from top to bottom in the file:/search for characters
For example, search for the string "word" in the file from top to bottom:/word
Search for the following string in the file :? Searched characters
For example, the string "word ":? Word
Locate the next matched string:N
Locate the last matched string:N
Unedit: Cancel the last operation once, and cancel the operation multiple times: u
Cancel all edits on the current row: U
Restore the undo operation with the u command: ctrl + r
Exit vi editor: Save the content of the current file and exit vi editor: ZZ or: wq
Save the current File: w save the current file and save it as: w save the path of another file
Exit without modification: q abandons modification to the current file and exits vi: q!
In the vi editorOpenEdit the new File: Path of file e
In the vi editorReadOther file content: Path of the r file
File content replacement: replace the first string found in the current row with: s/find content/replace content
For example, replace the first character "old" string found in the current row with "new ":
: S/old/new
Replace all strings found in the current row with: s/search content/replace content
For example, replace the string "old" that is found in the current row with "new ":
: S/old/new/g
Replace all strings in the range of the row number # and #: #, # s/search content/replace content/g
For example, replace all strings "old" with "new" in the range of row number 1,100 ":
1,100 s/old/new/g
Replace all strings in the entire file: % s/find content/replace content/g
% = ^, $
For example, replace all the strings "old" with "new" in the entire file ":
: % S/old/g