How to Use Vim
Tags: productivity, programming, vim, linux
Published: 2021-05-14 10:24:45

[Vim](https://en.wikipedia.org/wiki/Vim_(text_editor)) 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s5do19b8g8evk8jjd0w5.gif)

For beginners vim can be confusing, but it can boost your coding productivity. If you are new to vim, I recommend [these exercises](https://vim.is/)

## Installation :computer:

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:

Ubuntu: 
```
sudo apt-get install vim
```
OpenSUSE: 
```
sudo zypper install vim
```
Fedora: 
```
sudo yum install vim
```

## How to use vim :fire:

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.
```

* **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.

![power](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/izvqvbpn9szcflygymia.gif)

## Commands :penguin:

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lacvktwjelm9nz0r5cki.gif)

## Plugins :whale2:

Vim is also an extensible editor - a programmer can change the editor just by writing a new plugin. There are already hundreds of [plugins](https://github.com/topics/vim-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).