Linux knowledge point 2

1.
dirname path + file name ===> command to display the path
2.
a.vim path + file (vim /path/to/somefile) ===>
Open this file if it exists, create the file if it does not exist and open it in memory
b.vim +# path + file (vim +5 /path/to/somefile) ===>
After opening the file, the cursor is at line N
c.vim + path + file (vim + /path/to/somefile) ===>
Open the file directly at the last line of the file
d.vim +/*** /path/to/somefile===>
Locate the first line of the line matched by the pattern *** for the first time
3.
a. The last line of the file closes the file
:q quit
:wq save and exit
:q! Quit without saving
:w save
:w! Forced save (can be changed by senior executives)
b. Exit in edit mode
ZZ (uppercase) save and exit
4. Move the cursor (operate in edit mode)
h: move left #h: move left N characters
l: move right #l: move right N characters
j: move down #j: move down N characters
k: move up #k: move up N characters
5. Inline jump
0 (number): absolute line start
^: the first non-whitespace character at the beginning of the line
$: Absolute line ending
6. Move by word
w: move to the beginning of the next word
e: skip to the end of the current or next word
b: Jump to the beginning of the current or previous word
7. Jump between lines
#G: jump to line #
G: skip to the last line
Note: Just enter numbers in the last line mode
8. Turn the screen (operate in edit mode)
Ctrl+f: scroll down one screen
Ctrl+b: scroll up one screen
Ctrl+d: scroll down half screen
Ctrl+u: flip up half screen
9. Delete a single character
x: delete the single character where the cursor is
#x: delete # characters at the cursor position and backward
10. Delete command: d
a. In edit mode:
#dw, #de, #db delete the corresponding number of words
dd: delete the line where the current cursor is located
#dd: delete # lines including the line where the current cursor is located
b. In the last line mode:
StartADD , EndADDd
.: Indicates the current line
$: indicates the last line
+# means # line down
For example:
1> delete the contents of lines 10-20 --> 10,20d
2> From the current line, 5 lines down -->: .,+5d
3> From the current line to the 100th line -->: .,100d
11. Copy the command y
The usage is the same as d
12. Paste the command p
Note: The last deleted content will be placed in the buffer, so it can be pasted
p (lowercase): if deleted or copied as an entire line, paste below the line where the cursor is located
 If the deleted or copied content is not an entire line, it will be pasted after the character under the cursor
p (uppercase): if deleted or copied as an entire line, paste above the line where the cursor is located
 If the deleted or copied content is not an entire line, it will be pasted to the front of the character where the cursor is located.
13. Replace: r
Usage tips: In edit mode, find the character to be replaced, enter r, and write the content to be replaced after sub hi
Note: If you enter R, it means to enter the replacement mode to find the beginning of the content to be replaced, press the R key to write the content to be replaced
14. Repeat the previous editing operation
.: For example, the last time you run the dd command to delete 1 line, press the . key at this time, the last command will be executed
15. Undo the editing operation
u (undo): undo the previous editing operation, you can use u continuously to undo the previous n operations (n<=50)
#u: Directly undo the last # edit operation
16. Find
/PATTERN: top-down search
? PATTERN: Search from the bottom up
n: results down each lookup
N: Result up each find
17. Find and replace
Use the s command in retouch mode
ADDR1,ADDR2S/PATTERN/string/gi
g: stands for global replacement
i: case insensitive

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324843773&siteId=291194637
Recommended