# A Quick Guide to the Vim Text Editor

[Vim](https://en.wikipedia.org/wiki/Vim_(text_editor)) is a  text editor which is highly efficient. It is an improved variant of the vi editor, that is distributed with [UNIX systems](https://en.wikipedia.org/wiki/Unix). 

Vim is often called a "programmer's editor," and so useful for programming that many consider it an entire IDE. It's not just for programmers, though. Vim is perfect for all kinds of text editing, from composing email to editing configuration files.

The vim text editor is an extremely powerful tool for developers, but it can be difficult to master.  If you are new to vim, I recommend [these exercises](https://vim.is/)

## Install vim

If you're using a Mac or a Linux machine, it's likely that your terminal has vim built in, so it's worth being familiar with to work on those systems. 

If not, you can install vim with your package manager or test if vi is installed.

To install vim for Ubuntu, follow these instructions.

1: Open a terminal window and type sudo apt-get install vim

```
sudo apt-get install vim
```

2: If you want to get updated version of vim, open a terminal window and type sudo apt-get update

```
sudo apt-get update
```

3: Then type sudo apt-get install vim

```
sudo apt-get install vim
```

The installation process will take some time, after which all the commands of vim will be available.

![apt-get install vim](https://cdn.hashnode.com/res/hashnode/image/upload/v1622019695021/Mwutop0t9.png)

## Basics

To start vim, just type vim in the command line

```
vim
```

Then you can type `ESC` followed by `:e filename` to open filename.

To open a vim directly from the command line, type:

```
vim filename
```

Press `ZQ` to quit vim without saving. Press `ZZ` to save and exit.

To move the cursor, you can press `ESC` and use the keys `h`,`j`,`k`,`l`.  You can also use the arrow keys in vim.

![vim cursor keys](https://cdn.hashnode.com/res/hashnode/image/upload/v1622019697254/Z6GMX7O63.png)

Vim has modes. To switch to writing mode, press the `i` key or the `insert` key. To switch to command mode, press the `ESC` key.

To save your file press `ESC` followed by `:w`.

Press `:Explore` to open the file explorer. Use the `j` and `k` keys and press enter to open the file. You can also use `:LExplore`

{% asciinema https://asciinema.org/a/383101 %}




