Casbay Knowledge Base

Search our articles or browse by category below

Overview of the Vim Text Editor

Last updated: September 7, 2022
Estimated reading time: 1 min

Overview of the Vim Text Editor

Many articles in this knowledge base advise editing configuration files. However, we usually recommend using the text editor which you prefer. At Liquid Web, we would recommend vim. Vim, or its older sibling vi, are installed by default on nearly every server that we come across. If you do not yet have a text editor in your mind, read on to see if vim might work for you.

Overview of the Vim Text Editor

Vim Text Editor

1) Normal Mode

The biggest concept that beginning vim users need to know is the concept of modes. There are different editor functions, such as moving the cursor around and inserting text. We can accomplish them in different modes. Open up a file in vim:

vim example.conf

Then, you are immediately put into normal mode. Normal modes does not seem normal at first. If you press “j” in normal mode, the letter “j” does not appear. Instead, the letter “j” moves the cursor down one line. Positioning the cursor in this mode is completely done with letter keys. The most basic are:

  • j – one line down
  • k – one line up
  • h – one character left
  • l – one character right

While this may seem odd at first, switching from mode to mode actually speeds typing up. This means that you do not have to move your right hand over to the arrow keys. Moreover, you also do not need to move back every time you wish to reposition the cursor.

2) Insert Mode

To leave normal mode and start typing text, press “i” to enter insert mode. Insert mode behaves much more like the default mode in other text editors. There should not be any surprises.
When you are done with insert mode, hit the ESC key to get back to normal mode.

3) Command-line Mode

Command-line mode is used to perform a wide range of commands. To enter vim’s command line, hit “:” (the colon) in normal mode. This will drop the cursor to the bottom of the terminal. Here you can do things like:

  • Save your changes (write)::w
  • Quit out of vim::q
  • Quit without saving changes::q!

You can also combine commands to run them together. This is commonly done to save the file and quit vim at the same time:

:wq

After you have run a command, vim will place you back in normal mode.

Was this article helpful?
Dislike 0
Previous: Server Hard Disk Full? A Quick Guide
Next: Understanding Linux Based VPS Sudo Syntax And Sudoers File
Discover the perfect balance of performance and budget-friendly Dedicated Server plan !
Discover the perfect balance of performance and budget-friendly Dedicated Server plan !
High performance and low cost Dedicated Server plan 128GB from $185 – upgrade today!
High performance and cheap Dedicated Server plan 128GB from $185 – upgrade today!