VI (M) has a built-in VI (m) Editor in most Unix systems (including Linux. It is also a common text editing tool.
However, people who are used to the window text editing tool are used to moving the cursor with the mouse or the "up/down" key,
However, in some Linux/UNIX operating systems, VI does not support moving the cursor by the "up/down" key, which makes it a headache for some new users.
However, as long as you spend a little time figuring out its habits, you can use it easily !!
First, there are three modes of VI:
Normal Mode
In normal mode, you can only move the position on the cursor screen, Mark, delete, move, copy character or text block. In addition, you can enter the command column mode in command mode.
Input mode
You can enter text materials only in input mode. Press ESC to return to normal mode.
Command column Mode
You can also set the editing environment, such as searching for strings and listing row numbers, by writing files to or leaving the editor.
How to switch between modes:
◆ General mode ---- → editing mode: In general mode, press 'I', 'A', or 'O' to enter the editing mode.
"I" insert-Insert the text to be entered at the current cursor
"A" APPEND-Enter text in the next line where the current cursor is located
"O" open-Add a row under the cursor and input text from the beginning of the row
◆ Editing mode ---- → general mode: Press ESC
◆ General mode ---- → command mode: In general mode, you can press ':' or '/' or '? 'Key to enter the command column Mode
: W filename (stored in the specified file)
: WQ (write and exit VI)
: Q! (Force exit and discard the edited file)
: N [file]-introduce the next file
: L, l2d-delete text from self-built l to row L2
: Set nu (list row numbers)
: Nu (to line Nu)
/Word (search from the beginning to the end), press n to continue searching
Basic operations of VI:
◆ Move the cursor in Normal Mode
H, J, K, and l: control the cursor to the left, bottom, Earth, and right
◆ Some common operations in Normal Mode
CTRL + B: Previous Page
CTRL + F: Next page
G: Move to the end of the file
W: Move to the beginning of the next word
B: Jump to the beginning of a wore
X: Delete the next character.
DD: Delete the row where the cursor is located