The vi command is the most versatile full-screen plain text editor in UNIX operating systems and UNIX-like operating systems. The vi editor in Linux is called vim, which is an enhanced version of vi (vi Improved), fully compatible with the vi editor, and has implemented many enhanced functions.
Here are some tips for using the vi editor to facilitate subsequent log queries.
0 The cursor is positioned at the beginning of the current line, not in input mode $ (shift+ 4 ) The cursor is positioned at the end of the current line, not in input mode 1G file header (Note: 1 here represents the line number to go to, if you want to go to the 2nd line, it is 2G, here must be a capital G) G (shift+g or caps lock key+g) end of text A (Shift+a) end of the current line and enter the editing state ctrl+f page up ctrl+b page down ctrl+u half page up ctrl+d half page down Find: /pattern<Enter> : look down pattern matching string ?pattern<Enter> : Look up the pattern matching string Example: We want to search down for "password", just type "/password" and press Enter We want to search up "password", just type "?password" and press Enter After using the find command, use the following two keys to quickly find: n: continue searching in the same direction N: search in the opposite direction
From: Several command skills commonly used in linux
For more vi editor commands, please refer to: Linux vi command usage details: powerful plain text editor