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:
and then, press ‘i’ or the insert key and you are done. Vim will show you which mode you are in.
2 Run a command
First press Esc key which will make the screen look like this:
Then press ‘:’ (colon) and insert the command.
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:
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:
The paste mode converts tab character to space characters. To get out of this mode use:
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.
Then select text and after you are done press ‘y’.
Get into visual mode, select text and press ‘x’.
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.
Go to command prompt and:
9 Difference between two files
vim -d _file1_ _file2_
You would see something like this.
That’s all folks. Keep spreading the love for Vim.