Transitioning from Sublime Text to vim

Gokul Srinivas
Gokul’s blog
Published in
4 min readApr 2, 2017

--

Preface

I first started programming in school. Back then, it was a course on HTML. We used to write code on Notepad and open it in Internet Explorer. Somehow, I figured out that creating webpages on MS FrontPage was much less tedious (I was in 6th grade). Fast forward to grade 12, we were writing C++ on the Turbo C IDE. Well, at least it had better syntax highlighting when compared to notepad.

In freshman year, I was introduced to the world of linux. It was refreshing, it was awesome and it was everything I wanted from an operating system.
I had installed sublime text of course, courtesy of googling “best editor for programming”.

I was trying to get into one of the best programming clubs in my college, and I was experimenting like crazy with linux. I installed all sorts of software — supported, unsupported, backported, you name it. Most of the time, something broke. I would end up googling it and changing configuration files or system files. I used vim for this.At this point, I was okay with a modal editor. I wasn’t particularly inclined to vim but I wasn’t repulsed either. Contrary to popular belief, I was able to quit vim without dying.

Sublime text has a lovely set of plugins and it really did help me program faster. The most essential features that I used were — auto-indent, brace completion, syntax highlighting in multiple languages, jumping quickly between files, sidebar, and the multitude of colour schemes available amazed me. I would change my colour scheme every few days.

As I got into Delta, the programming club, I noticed a few things. Most of the best and fastest programmers used only their keyboard. No mouse.
I was quite dependent on my mouse. I still felt it easier to navigate within my file with my mouse / trackpad. Moreover, most of them were programming and doing various other things on the terminal. They never switched back and forth between apps. Many were also hot-fixing and testing code on our web server over ssh. You really couldn’t open sublime text via ssh and that got me back to using vim.

I sat down and analysed the advantages of using vim all the time. I really needed to learn touch typing but after that, the benefits were tremendous. I didn’t have to leave the home row on the keyboard or use the mouse.

Enter vim.

I was familiar with vim and touch typing really improved my speed a lot. At this point, I started listing down my most used features on sublime text and proceeded to figure out how to emulate the same on vim so that I could be most productive.

I first had to settle on a good plugin manager for vim. I settled on vim-plug.
It is lightweight, fast and had all the features that I was looking for.

The list of features that I used (mostly) were:

Including a lot of plugins is one thing, performance is another. I expected blazing fast startup times without having to do things like running it as a daemon (yeah, I’m looking at you emacs). I installed all the above plugins and then started vim.

I was mind blown. Vim still opened up instantaneously (~158 ms). All my plugins worked really fast and I was still as productive as in sublime text, if not more. Here’s the log of the startup time.

No daemon, no hack, just vim.

Usage

The easiest way to start using vim is to install vim and type ‘vimtutor’ in the terminal. It is a 15 minute entry into the world of vim. Once you grok vim, you’ll never ever go back to anything else.

Learn about motions, for example, going to the matching brace (‘%’) or going to the end of the third word from your cursor (‘3e’).

Going to the matching brace.

The multiple cursors from sublime text can be replaced by the visual block mode (ctrl-v) or by using macros. Simply record your set of actions into a register and use it as you please.

One of the instances where you’d use multiple cursors.

There are loads more tips and tricks. Mastering the plugins gave me so much more productivity and I was able to write code much faster.

One such plugin is EasyMotion. It allows you to move across the screen with blazing fast speed. Do check it out.

The trick to mastering vim is to just keep using it. You’ll soon realise that your most used commands just come to you. You don’t even think, it just happens.

Epilogue

I became even more productive as I kept using vim. Many things became muscle memory. I added some more plugins and became even better with vim. The startup time I mentioned earlier is with my current .vimrc.

I was also educated in the merits of backing up my .vimrc on the cloud. I now have my .vimrc on github and a small script to help me install it faster and get me running faster. You can find my .vimrc here.

Food for thought: Why do you think emacs has a vim mode (evil-mode)?

--

--

Senior year Computer Science undergrad at NITT. Software Engineer, Quizzer, Violinist and loves technology.