What does the long way mean? It means Vim didn't stick for me until well after a year of first trying to learn it. Multiple dips into Vim, especially if you can do it while your motivation is high, over a sufficient period of time, will lead to a tipping point. This is how I came to my own tipping point with Vim.
To hear Vim users, and yes emacs users too, talk about how much they love their editors can really make you feel like you are missing out on something cosmically amazing. Personally, I thought it was 50/50 on whether they had actually unlocked something valuable or had Stockholm Syndrome after such a long period of suffering. But still, once you have watched someone who is amazingly productive in Vim, it's hard to get the thought out of your head that you could be (a lot) more productive. To watch someone accomplish in a few fluid keystrokes everything that they need before your hand can finish reaching for the mouse is awe inspiring in the singularly nerdy way that only those who write code into a terminal for a living (or fun) can be inspired.
But, you know why you're here. You want enlightenment. You want to hear it's worth it. All the time and the struggle and brain hurt of trying to remember what motion gets you where. You want to be done already. And you can be, but I would suggest that you take the long way to get there.
(don't) Delete the Editors!
I'm sure you've heard deprivation stories before. What's a deprivation story? It's when a new analyst starts at a bank and to force them to learn Excel keyboard shortcuts their mice are taken away. For programmers it's uninstalling all other editors and forcing yourself to use Vim until you get good at it. If you go really deep it doesn't stop there either, I heard Ben Orenstein recommend once that you should lower your key repeat rate to force yourself to learn better navigation instead of using hjkl as a crutch. The path to enlightenment is never done.
For me, and I imagine if you're reading this, for you also, the deprivation angle didn't work. My theory on why it doesn't work is because if you are interested in using Vim you are probably interested in being more productive and a program that causes you to regress to what feels like your first touch typing lesson is frustrating. In the short term it's definitely counter productive.
But, I hear you say, I learned touch typing by just gutting it out and you can learn Vim this way to! This is, of course, technically true. I doubt you would quit your job if you could only use Vim and after a period of time you would become proficient with it. That period to proficiency would also probably be shorter, if more painful.
Why doesn't everyone do this?
One, we aren't starting from 0. When you first learned to touch type you had no other option to than to get through it (or live with your hunt and peck shame forever). This is the nature of beginning something wholly new. If you are already writing code though, typing isn't wholly new and Vim can represent a step backwards.
Second, for most of us this isn't a theoretical exercise (unless you are in college or otherwise have extra time on your hands, then I encourage you to try whatever drastic approaches you want), most of us have to produce things and if you're reading this blog, you probably have to produce characters, lots of them, in not enough time.
What Worked for Me
Here are the steps I took over the course of about a year that finally got me switch over to Vim full time:
vimtutor, got the basics, finally understand what this actually is
- Try to use some Vim and a lot of Googling to write real files, give up when frustration reaches crtical mass, repeat for months
- Try VimGolf, get more frustrated, decide Vim was a stupid idea anyway
- Start popping open Vim for specific edits based on known skills, it's becoming a part of the toolset
- Actually invest the time to manage
~/.vimrc; amazement returns, but still far faster in old editor
- Find a few plugins that handle specific annoyances, opening up Vim more and more
- Discover something amazing (was ctrlp for file navigation for me); begin guessing at commands that "should" work and they do
- Experience the tipping point: realize it would be faster to do something in vim, close other editor, vow to never come back
- Realize that other editors are often still good for creating files, so, in the end, it's not all or nothing
The Secret: Deliberate Customization
As I look back over that list I see someone grappling with the basics, gaining proficiency then finally mastery (then the final final step of realizing it's not some panacea that solves everything). What really made Vim worthwhile though was customization and plugins.
Start Out With Something (but not too much)
Customization will make any editor more comfortable. With Vim, however, I would argue you must customize to be productive. This isn't a new thought, there are a lot of bundles that dump in a bunch of config and customization into Vim all at once. The downside is that these bundles separate you from customizing Vim yourself. It becomes like just another editor with behavior you may not like, but limited ability to change (is that a Vim behavior or did it come from the bundle?). In the end you want your Vim config to be a special snowflake, your special snowflake.
After trying out some of the bigger config dumps, this was the one that worked for me. It's not too big and the changes are nice QoL increases. One note, I would remove the Vundle loader. Vim packages makes this unnecessary and if you are just starting out, I'd suggesting going this way as it seems like the future and is built in. Here you can read a longer discussion about packages.
A (very) short list of things to change now
Here is a deliberately small number of things that I would change right now as you are experimenting with Vim:
- Remap capslock to escape. Esc just too far away and too small and you're going to be hitting it all the time (and you're out of luck if you have a Mac without one).
- Remap your leader key. Mine is ',' but it doesn't matter what it is only that it's comfortable for you and your workflow.
- Get a file navigation plugin (I use ctrlp, but find one you like). This alone will make you faster in Vim.
- Take the time to groom your
wildignorelist. Don't waste time returning files you aren't going to open anyway.
- Set a small number of leader commands that you will use right now. Work in Rails and always checking the schema? Try
map <Leader>db :sp db/schema.rb<cr>. Work on files where spelling is important?
map <Leader>sp :setlocal spell spelllang=en_us. Whatever you pick make sure you use them often so they stick. This will grow just like your alias list in bash.
So take heart. You can learn vim. Just take a break when you need to. It will still be there when you come back.