Save the changes

To save the changes to the file in the Vim editor enter command mode and use the following command,

Command

Description

:w

Write to file called [file_name] (save as).

:w!

Overwrite to file called [file_name] (save as forcefully).

:wq

Save the changes and quit the editor

Basic Vim Commands

In this article, we will cover some basic commands in the Vim editor. First, we look at what Linux and VIM editors are and why we use them, followed by basic commands in Vim editor starting from creating/editing a file, different modes, quitting the editor, saving the changes to the file, navigation in the editor, deleting lines, displaying and hiding line numbers, search and replace, and syntax highlighting along with the syntax of commands and screenshots.

Linux

Linux was developed by Linus Torvalds in 1991 as a hobby project. It is an open-source (source code that can be used by anyone freely) kernel that is most popular and widely used in the industry as well as in personal systems. There are various operating systems based on the Linux kernel, some of the popular Linux distributions are Ubuntu, CentOS, Red Hat, Debian, and Kali Linux.

VIM Editor

Vi Editor is a widely used text editor in Unix/Linux systems and is known for its efficiency and flexibility. Vi editor was developed in 1976 by Bill Joy and later in 1991, an improved version of Vi editor was released which is known as VI Improved (VIM).

Basic VIM Commands

  • 1. Create/Edit a file
  • 2. Changing modes in the Vim editor
  • 3. Quit the Vim editor
  • 4. Save the changes
  • 5. Navigation in Vim editor
  • 6. Delete a line
  • 7. Search and Replace
  • 8. Display Line Numbers
  • 9. Hide Line numbers
  • 10. Syntax Highlighting

Similar Reads

1. Create/Edit a file

To create/edit a file in the Vim editor run the below command...

2. Changing modes in the Vim editor

There are Six modes in Vim editor....

3. Quit the Vim editor

To quit the Vim editor enter command mode and use the following command,...

4. Save the changes

To save the changes to the file in the Vim editor enter command mode and use the following command,...

5. Navigation in Vim editor

We have covered the navigation in Vim editor in a detailed article at GFG which you can check here....

6. Delete a line

To delete a single line Press the Esc key if you are in insert/editing mode, go to the file you want to delete Press ‘dd’ and then the line gets deleted....

7. Search and Replace

To find and replace words in the vim editor we use substitute or:s command syntax of the command is as follows:...

8. Display Line Numbers

To display absolute line numbers use any of the following commands,...

9. Hide Line numbers

To hide absolute line numbers use any of the following commands,...

10. Syntax Highlighting

To Enable syntax highlighting type the below command and press Enter....

Basic Vim Commands -FAQs

How to delete the current line?...

Conclusion

In this article, we covered basic commands in Vim editor starting from creating/editing a file, different modes, quitting the editor, saving the changes to the file, navigation in the editor, deleting lines, displaying and hiding line numbers, searching and replace, and syntax highlighting along with the syntax of commands and screenshots. Thereafter we discussed some of the frequently asked questions (FAQs)....