DEV Community

Cover image for How to Use Vim

Posted on

How to Use Vim

Vim is a powerful text editor used by programmers and system administrators as a command line interface. Vim is widely used by Linux users. It is also available in Windows, Mac OS X and every other Unix system.

The reason why it is that popular is that vim allows the programmer to code efficiently without leaving the editor. When coding, you don't need to use your mouse. This sounds simple, but this is exactly what any programmer wants from an editor.

Most of its commands are robust and cryptic enough to be typed in blindly, which makes it a good choice for operating on remote servers without a GUI interface. But you can also use vim mode in your favorite IDE to increase productivity.

vim productivity

For beginners vim can be confusing, but it can boost your coding productivity. If you are new to vim, I recommend these exercises

Installation 💻

The following is a very simple and quick installation of Vim on any Unix-like system. These instructions are geared towards systems with GNU coreutils, but it should work equally well on other systems with minor modifications.

Most likely vim or vi is already installed on your comptuer. But if not, you want to install Vim, so run:


sudo apt-get install vim
Enter fullscreen mode Exit fullscreen mode


sudo zypper install vim
Enter fullscreen mode Exit fullscreen mode


sudo yum install vim
Enter fullscreen mode Exit fullscreen mode

How to use vim 🔥

Here are some basic commands that will help you navigate the text files using Vim. To enter commands press ESC first, to write press i.

  • Open file

To open a file in Vim, you can type

vim filename.
Enter fullscreen mode Exit fullscreen mode
  • Save file

To save a file in Vim, you can type :w.

  • Quit

To quit from vim, you can type :q. This command will also save the changes of the file.

  • Open another file

To open a new file, you can type :e filename. This command will open the file and move the cursor to line number one of the file.


Commands 🐧

Vim is a modal text editor. It's a tool with a long pedigree, and is to computer text editors what Microsoft Word is to word processors. It has two modes:

  • command mode
  • insert mode

In command mode (ESC), you'll type a series of commands to perform edits, such as typing text or searching the file system.

In insert mode (i or Insert), you'll type text like you would in any other text editor. Vim has many features that make it popular, but its most distinctive feature is probably its modal design.

vim commands

Plugins 🐋

Vim is also an extensible editor - a programmer can change the editor just by writing a new plugin. There are already hundreds of plugins for vim.

Some plugins make vim behave like an IDE (integrated development environment). Do note that IDEs often have vim emulation mode plugins themselves.

Others provide syntax highlight for hundreds of programming languages. For example, there are more than 20 syntax-highlight plugins for javascript (including CoffeeScript, LESS, Sass, and Stylus).

Top comments (0)