paint-brush
My Vim crash courseby@drodil
3,276 reads
3,276 reads

My Vim crash course

by Heikki HellgrenMarch 13th, 2018
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Vim (as in Vi IMproved) is a popular text editor used by many programmers and sysadmins around the world. Just few weeks ago I faced the truth that I don’t master this praised tool and never really used it for real development. I decided to do something about it and started learning. This story is about experience with the tool this far.

People Mentioned

Mention Thumbnail

Companies Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - My Vim crash course
Heikki Hellgren HackerNoon profile picture

Vim (as in Vi IMproved) is a popular text editor used by many programmers and sysadmins around the world. Just few weeks ago I faced the truth that I don’t master this praised tool and never really used it for real development. I decided to do something about it and started learning. This story is about experience with the tool this far.

Vim— You either love it or hate it

Background

I have always used GNU nano for console file editing and some IDE (Eclipse, Netbeans, you name it) for actual work. Only thing were I have used Vim was with my git commit messages so my know-how was limited on how to insert text and how to save the file and quit the editor.

Few weeks ago I was on business trip at Germany and got really bored in the hotel room. I accidentally bumped into a Youtube video of C++ developer showing off programming using Vim and tmux. It all looked very easy without any huzzle with the mouse cursor or finding things from IDE’s dropdown menus. This made me think if learning and especially mastering Vim could help me be more productive and save nerves — not only in my brains but also in my mouse hand :)

C++ development with Vim + tmux

Square zero

I started the journey by installing the latest version of Vim (8.0) which was easy peasy task after single Google search. After getting the editor installed, I jumped straight to try and edit some source files of the project I am working on. This was not a good idea and I found myself going straight to the insert mode and scrolling down with arrow keys like an idiot. I was afraid that this was not going to end well so I started to dig some more information how people have learned how to use this tool and where I could find more resources.

I came across, of course, the vimtutor which is a command-line “tool” that teaches you the basics of navigation in the editor. After completing that few times a row I started to understand a bit better how the editor works. Also during the same trip I played the famous Vim Adventures — a web browser based game teaching you some of the most used commands in vim in very fancy way.

Still the editor did not convince me like I thought it would.

The famous learning curve

All comments around the internet talk about how steep the learning curve for Vim is. I don’t know if I can agree. Understanding and using the basic commands is quite straight forward and it will remain in your muscle memory quite fast with proper practice. In fact, I would say the learning curve is not steep — it’s long. Vim allows you to customize a lot of different things from plugins to key mappings in different modes and from themes to text formatting settings. Getting all these settings the way you want them to be can (and will) take you some time. Of course you can work without any extras but especially in C++ programming you really want some help from autocomplete features and other nice things that make you even more productive.

Plugins, plugins, plugins

One of the things you can really spend a lot of time are the Vim plugins. There is tons and tons of different plugins for different use cases and finding the best match, configuring it for your needs and learning to use it is very time consuming.

Best way to find good plugins is page called Vim Awesome and there is one liner installations for different plugin managers (Vundle, NeoBundle, VimPlug and Pathogen). I recommend is that you should use one of these plugin managers as otherwise it is pain in the ass to get everything installed properly.

Configuring plugins can be easy or then it’s hard — it all depends on the plugin. Also one thing I recommend is that you install one plugin at a time and learn to use it before adding anything else. Sometimes the plugins might collide with each other (with keymappings especially) and cause a lot of problems.

My configuration

Space for improvement

Vim should not be something you stop learning once you get your development up and running. You should always try to learn something new and how to get things done with fewer keystrokes. Personally I haven’t yet got any major real programming done with the editor but I am getting there.

Here is a list I think you should check to improve your Vim skills:

  • Find a Vim friend. This is really important especially if you are a novice and you can find a friend who has worked with Vim for longer time. You can share your findings of plugins and good configurations and you can always ask for help (from my point of view Vim users are keen to help others to use the tool)
  • Find good configurations. There are lots of good .vimrc configuration files available in the internet you can try out with very little effort (for example this). You can find more just by searching for “dotfiles” repositories in the GitHub.
  • Create your own dotfiles repository. This is very good idea if you are doing work on different machines. You can easily just clone the repository and apply the configurations you need on specific machine. Also it keeps your history of configuration changes nicely in the version control. If you are interested, you can check my dotfiles repository at https://github.com/drodil/dotfiles
  • Don’t stop learning. Maybe the most important thing is that you keep learning every day. Learn something new whether is a new plugin, new key combination or configuring and keep doing this — you will get there eventually.

Final words

I did not find anything wrong with vimtutor but I still decided I would make my own tutor that would concentrate on key mappings that are more useful in programming. I will continue the work whenever I have time and most probably distribute it on my Github account for people to try it out.

Even though I have only been learning this great tool for about a week now, I can say it looks very promising and I can see why people really like it. I have a gut feeling that it will take at least a month until I can bypass my productivity compared to using an IDE but I can see that it will pay an effort anyways.

If you haven’t tried to learn it I strongly recommend. It can be frustrating but it’s also very rewarding once you get something concrete done (also it looks pretty “hackerish” for other people ;))

Discover more

  • Vim Master — Android game that teaches you the Vim key mappings. Awesome for long flights ;)
  • Vimcasts — Screencasts from people using Vim and explaining different things and how they work

Please also check part 2 of the crash course here!

About me

I am Heikki Hellgren, Software developer and technology enthusiast working at Elektrobit Automotive. My interests are in software construction, tools, automatic testing and all the new and cool stuff like AI and autonomous driving. You can follow me on Medium and Twitter. Also you can check out my website for more information.