Linux study notes (3) -- Overview of vi and vim editors and three modes

viand vimoverview

  • Linux systems have built-in vitext editors.
  • vimis via text editor developed from . viA similar enhanced version with program programming capabilities . It is particularly rich in functions that facilitate programming, such as code completion, compilation, and error jumping.

viand vimthree commonly used modes

  • Normal mode (default mode)
    to vimopen a document, the default mode is the normal mode. In this mode, you can use "up, down, left, and right" to control the cursor, and you can use copy and paste to operate file data.
  • Insert mode (editing mode)
    In normal mode, press any one of i, I, o, O, a, A, to switch to insert mode. Usually used .Rri
  • Command mode
    In this mode, operations such as reading, saving, replacing, exiting vim, and displaying line numbers can be completed.

viAnd vimpractice creating and editing the Demo.java file

1. Open the terminal, enter the following command, and press Enter to enter the default mode (as shown below).
vim Demo.java

Normal mode.png

2. Enter any one of i, I, o, , , , to enter the insert mode (as shown below).OaARr

Insert mode.png

3. Enter the simple demo code.
public class Demo{
    public static void main(String[] args){
     System.out.println("Hello world");
    }
}
4. Press ESCthe key and then enter the key to switch to the command line mode (as shown below).

Command line mode.png

5. In command mode, enter wq(meaning write and quitwrite and exit), press Enter, save and exit.

Demo file creation completed.png

6. After exiting, if you want to continue editing, you can enter the following command, press Enter, and continue editing.
vim Demo.java

Summary of vim three mode switching

vim three modes.png

  1. Enter vim normal mode.
  2. Enter i, I, o, O, a, A, R, rto enter editing mode.
  3. Press Escto return to normal mode.
  4. Enter or /to enter command mode.
  5. Press Escto return to normal mode.
  6. In command mode, enter :wq(save and exit), :q(exit), :q!(force exit without saving) to return to the command line terminal.

Guess you like

Origin blog.csdn.net/qq_22255311/article/details/123152927