Taking a minute to love Vim

Hello,

This article is a result of my love for Vim and not a single programmer would leave Vim without mocking. In fact, leaving Vim is considered tougher than getting a job interview from Google (insert your favorite Tech company here šŸ˜Š). Vim is the best editor to work on a Linux system. So here’s the getting started to Vim guide, which will be enough if you want to use it to write everyday code.

1 Insert something in a file

Open the file with Vim:

vim _filename_

and then, press ‘i’ or the insert key and you are done. Vim will show you which mode you are in.

screenshot-from-2016-09-20-00-42-55

2 Run a command

First press Esc key which will make theĀ screen look like this:

screenshot-from-2016-09-20-00-48-28

Then press ‘:’ (colon) and insert the command.

screenshot-from-2016-09-20-00-50-03

3 Exit Vim

Press the Esc key and then press colon and then press ‘q’ (quit).

If you want to quit without any warning you do:

:q!

Otherwise, Vim will show a warning that you are trying to quit a file without saving it.

4 Paste text without disturbing alignment

Use the paste mode:

:set paste

The paste mode converts tab character to space characters. To get out of this mode use:

:set nopaste

5 Copy

Forget Cltr + C, with Vim its even more easy (Wow, it rhymes šŸ˜Ž)

Put the cursor from where you want to start copying. Then press Esc and then ‘v’. You will get into theĀ visual mode.

screenshot-from-2016-09-20-01-45-41

Then select text and after you are done press ‘y’.

6 Cut

Get into visual mode, select text and press ‘x’.

7 Paste

After copying theĀ code, go to the character you want to paste and:

Ā * ‘p’ to paste after the character you are on.

 

* ‘P’ to paste before the character you are on.

8 Undo

Go to command prompt and:

:u

9 Difference between two files

Use:

vim -d _file1_ _file2_

You would see something like this.

screenshot-from-2016-09-20-02-05-17

That’s all folks. Keep spreading theĀ love for Vim.

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s