Vim Text editor can efficiently help us quickly create or modify some common text type files, such as configuration files:

img

Check vim's definition and usage

Create File

1
vim newfile    # After running the command, it'll create an empty file called newfile
img

Create a new file

Command Mode

Vim opens a file in command mode:

img

Command mode

Help

We can view the command-related help by the :help command:

1
:help
img

Before pressing the Enter key

img

After pressing the Enter key

To go back to command mode, just type :q and press Enter:

1
:q

Insert Mode

We can press the letter i on the keyboard to enter to insert mode:

img

This is shown at the left bottom of the screen

Let’s write something:

img

We have wrote something in the insert mode

We can press the ESC key to go back to command mode:

img

The -- Insert -- text shown at the left bottom of the screen has gone

Command Mode Operations

We can do a lot of things in command mode, such as searching, undo changes, save, exit files, and other more advanced uses.

Save

We can type the :w command in command mode and press enter to save the file:

1
:w
img

Before pressing the Enter key

After we save the command, we can see some basic information about the file at the bottom: of the screen

img

After pressing the Enter key

Exit

If we have saved the written content, we can exit vim by :q command and press Enter:

1
:q
img

Before pressing the Enter key

Edit File

Opening a file is almost the same as creating a file:

img

Edit an existing file

The difference between an existing file and a new file is the basic information at the bottom of the screen after the file is opened, the existing file has the basic information, and the new file has nothing:

img

After opening an existing file

References Basic Vim Commands Every Linux User Must Know

If you think the content of this article has helped you, and if you would like some more high-quality materials in the near future, please give me some modest support.

Buy me a coffeeBuy me a coffee