I started hearing a lot about vim three years back. When I was in the first year of college, we had to SSH into the university server to write C programs through putty. Available editors were nano and vi. Then I wasn't aware of the power of vi and in fact, nano and vi looked alike to me except that fact that it seemed impossible to be used by human kind. It wasn't a long time before I started realizing that people actually use vi and that it can replace even full-fledged IDEs.
Well, the main problem with vi back then was that I even found it impossible to even move around with the arrow keys, apart from the fact that I didn't, like most of the rookies, know how to quit vi. Then came this advanced version of vi - Vim (vi improved) after which it became easy for me to move around with the arrow keys.
How I started using Vim?
Learning Vim isn't that hard on contrary to the popular belief. It took me two hours to understand what Vim is and another two hours to learn the basic things I can do with Vim like opening and closing the editor, editing and saving a file, etc. The thing the helped me the most in the beginning was the
vimtutor. It's a command-line tutor to learn to use Vim effectively. You can type
vimtutor in the command line to start it. All basic and intermediate information you need to know is covered in it already. So, if you want to start using Vim or has just started, I recommend to you the builtin
vimtutor before watching the cool tricks people do with Vim on Youtube.
Few things to know before starting to use Vim
The following are the two things one should be aware of before starting to use Vim:
- Vim can be switched to different modes like the Insert mode (when you type code in Vim) and the Normal mode (when you can't type code but you think and move around your cursor or delete or copy lines). There are other modes too that you can worry about later.
- Vim is highly configurable to your liking. This means that you can make your Vim beautiful as much as you can add shortcuts/key mappings to an infinite number of ways.
The following is a screenshot of my Vim taken while this blog post is made:
My dot files are available here : https://github.com/kevinisaac/dotfiles
I don't like to bloat my Vim with too many plugins in favor of Vim load speed. The following are some of the plugins and themes I've used.
Vim Vitamins Theme - I've made a few alterations here and there to the original theme to my liking.
NERDTree - NERDTree is an in-editor file explorer. It helps you view the directory structure of the file you are working on for example. I usually tend to avoid using it as it takes a considerable amount of space; I like to use the maximum amount of editing space possible ;).
IndentLine - This is another plugin to show the code indentation inside files with a single character width. Previously I was using vim indent guides but dropped it in favor of the beauty of IndentLine.
Emmet Vim - Emmet is another amazing plugin for creating HTML and CSS snippets. The emmet snippets are more like abbreviations to create multiple HTML elements with the required properties and then pressing the magic key to expand them all at once. Emmet is also available for other editors like TextMate and Brackets.
Vim Snippets - It is used to create snippets for any programming/scripting language. You can define short code placeholders for most used code snippets and expand them which saves you a lot of your valuable time.
There are a few other great pieces of vim plugins but these are the most commonly used ones by me.
Use how you want to use Vim
You may hear a lot of advises about using Vim and the most common one you'll hear from hardcore vim users will be not to use the arrow keys. It is true that it may account for faster coding but it's ultimately about how you feel about it. I personally use the arrow keys instead of the
h j k l keys because I'm used to navigating with the arrow keys while using the browser and other tools too.
Also, if you feel like using the mouse while getting started in using Vim, don't hesitate. The initial difficulty or the steep learning curve while starting off with Vim is the most and possibly the only frustrating part of your entire experience with Vim. So do anything you want to do, to be sane until you climb onto the initial learning curve. Once you get past it, there is an infinite amount of options you have to make Vim your powerful friend.