Did I wake up on the wrong side of the bed?
My New Year’s resolution for 2013 was to learn Vim. I was so new to Vim that I did not even know how to join lines properly. However, I was diligent, patient, and stubborn enough to stick at it. It didn’t take long for me to fall in love. I even ended up writing a plugin for Vim that got so popular that I was writing VimL as a second job.
Sounds like I’m pretty happy with Vim (and I am), so why am I trying Emacs?
Curiosity is a major reason. But more I think the philosophy of Emacs fits my personality better. The Vim community is very much divided into two camps: the text editor people, and the people who try to turn Vim into an IDE. I am in the latter. My vim distribution has over 90 plugins. While I haven’t yet run into Vim’s limitations of trying to use it this way, I can already see the walls coming up…
But here’s the thing, I’m addicted to modal editing, not Vim. Read on...
First off, there are two very good resources that are required reading in addition to what’s provided in the official documentation. Steve Losh’s Learn Vim the Hard Way is an excellent book and I highly recommend it. The IBM Series by Dr. Damian Conway is another great resource. Without these I would not have been able to do what I have achieved, so thanks to them!
When I first wrote vim-bufferline and vim-airline I was very much a newbie Vim scripter and I tried to follow as many existing patterns as possible. It was evident that the community at large had a very “C-like” mentality, in that most things were done with functions declared in the global scope (I don’t know if this still holds true for modern C development, but as an expression I think people will get what I’m saying). Many of the older scripts (pre GitHub) tended to be large, single file plugins which lived under the
plugin folder. For example, EasyGrep is a 3000+ line plugin that helps you search and replace in Vim.
I’ve been having a small itch for a while now, and it’s a very simple thing – I want to make my tab smarter. This all starts with a dive into Emmet. To understand what it is, here’s a quick introduction. First, you type something using its syntax:
and after you “expand” it, usually with a hotkey, and it gets converted to
<div> <li></li> <li></li> <li></li> <li></li> </div>
As you can imagine, this saves you a lot of typing and lets you prototype a web page (or CSS) in no time once you learn the syntax. It is snippets on steriods! The Sublime plugin handles this perfectly. It maps
<tab> as the expansion key. Hitting tab after typing
div>li*4 will expand it and put the cursor at the first
<li>|</li>. Then after you type something, if you hit
<tab> again, it will jump to the next
li. It is smart enough to know whether to expand or jump to the next tag.
So how does this functionality look like in Vim? Read on...