Vim/Vi tutorials For beginners
Tags: javascript, beginners, vim, java
Published: 2019-08-20 18:30:10

---
title:Vim/Vi tutorials For beginners
published: true
description:Vi editor's basic usage and the vimdiff to compare two or more files all together to resolve merge conflicts and etc
tags: #javascript #beginners #vim #java
---

Most of the people tired off using Vim, and I do faced the same problem. But, in the actual case, it’s not a big deal. The thing is, we should understand the basics to use that.

First, Launch your fellow terminal then,

Open any file, that you wanted to edit. In my case -I’m opening main1.java by using the below command

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/y2nxz0lfm0bq66aggexz.png)

To edit the file or to insert any characters in that file, we need to get into- “INSERT mode” by pressing the

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/y07cpfetzc1rgksvvtff.png)

Now, edit whatever u need to, by moving the cursor forward and backward by using your arrow keys, and deleting the contents using your backspace key

Now, its time for saving the contents…nooo don’t use ctrl+s -that fellow won’t work here.., Here its about what mode we are in -Now, we are in the INSERT mode-So, we have to get into command mode to make our command to work, For that, press

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/oy3tti0uwzmrwc3y94uq.png)

Now It’s time to exit, right? then press

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/mipkvtiwpanph7t5tge5.png)

To copy and to paste the things inside the terminal, we use a different terms -which is “yank” and paste.

Note that “yank” will copy the contents to the terminal’s own clipboard -it won’t let you copy outside ( for copying it to the system’s clipboard — read about +clipboard )

For yank, go to “VISUAL LINE Mode” by pressing the

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/xfqzbuhqrk77son6lz8p.png)

So, that we shall notice terminal showing us the term “visual mode” in its bottom. Now just simply drag the mouse or use down arrow to select mulitple lines inorder to do some operations. Now , yank by pressing the

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/ebgauxgpbi3hshpmk5is.png)

Some Shortcuts will make this process cool. They are

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/swt3tzq3hji7mdsulcxy.png)

Now let’s move on to vimdiff , with the following command to compare the files where we use this more often to resolve the merge conflict.

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/4dl9oc9fw5ih9y355f8x.png)

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/ltzw8cmb2opiid6sgux9.png)

From the above pic, it is sure that we can easily find out the differences between the files , pink spots are for the modified area, and the blue is for the missed out lines ( either removed or added)

Shortcuts to access this window

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/h51eop3k6a2jje8por8x.png)

Now, to resolve the change conflicts -just move the cursor where you wanted to change and use

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/6qx7cn5eig0hvgv72hgw.png)

ie.,
If the cursor is on the line where the pink highlights are depicted on the first window for instance,

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/79iranijimw85sx8ywbg.png)

For your convenience, better use simple “yank” and paste as I told earlier. And at last, don’t forget to save and close which is

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/m7xw6n8kf691m739u146.png)

And there are still many features available in the vim, but what I told now is more enough to manage the files in the vim…
Have a nice day!!


Also Clap me on my Medium Page:
https://medium.com/@rdharan/vim-basic-cheatsheet-for-beginners-297190fc8331