Linux--- vi text editor

 

Table of contents

1. Command mode

 1.1 Cursor movement

 1.2 Copy and Paste

 1.3. Delete

1.4 Other common operations

 2. Insert mode

3. Bottom line mode

3.1 Commonly used commands are as follows

 4. Switch between the three modes

4.1 Switch between command mode and insert mode

4.2 Switch between command mode and bottom line mode


      The vi text editor is a commonly used text editor in the linux system. You can directly open the specified file by entering the vi file name in the terminal. If there is no such file, you can also create a successful file after entering the edit file. The vi editor has three working modes: command mode, insert mode, bottom line mode

1. Command mode

        After using the vi editor, it enters the command mode by default. In this mode, the movement of the cursor can be controlled by the keyboard, and text content can be copied, pasted, deleted, etc.

 1.1 Cursor movement

        In the command mode, the movement of the cursor can be divided into 6 commonly used levels, namely character level, line level, word level, paragraph level, screen level and document level

 1.2 Copy and Paste

        Copy and paste documents

 1.3. Delete

        Delete the content of the document

1.4 Other common operations

 2. Insert mode

        The content of the document can only be modified in the insert mode, and the insert mode and the bottom line mode cannot be directly switched

3. Bottom line mode

        The bottom line mode can save the file, and also perform operations such as searching and exiting the editor.

3.1 Commonly used commands are as follows

(1) :set nu: set the line number, which is only valid for this operation. When reopening the text, if you need a line number, you need to reset it. (2): set nonu: cancel the
line number, which is only valid for this operation.
(3): n: Move the cursor to the nth line.
(4): /xx: Search for "xx" in the file. If the search result is not empty, you can use "n" to find the next one, and use "N" to find the previous one.

(5) Bottom line mode can also perform content replacement

 (6) After the operation is completed, if you want to save the file or exit the editor, you can first use "ESC" to enter the bottom row mode, and then use the keys in the table to complete the required operations.

 4. Switch between the three modes

4.1 Switch between command mode and insert mode

        In general, press the i key to enter the editing mode directly, and the content is the same as the cursor position and command mode at this time, and the other keys:

Use the esc key to return to command mode from insert mode 

4.2 Switch between command mode and bottom line mode

        In the command mode, use the input ":" or "/" key to enter the bottom line mode. If you want to return to the command mode from the bottom line mode, you can use the esc key. If the bottom line is not empty, you can press the esc key twice. Clear the bottom line and return to command mode

 

 

 

Guess you like

Origin blog.csdn.net/weixin_64428129/article/details/127411906