My Stuggle With Vim
For a long time I had read and listened to people telling me how excellent Vim was and why it was better then X, Y and Z. Honestly though it has taken my a really long time (say 2 years) to become what I would call average at Vim and understand why it is actually a useful tool.
How to improve your vim skills (for those starting from the beginning)
- Learn to touch type (probably the most important step)
- Write your own vimrc
- Read This
- Disable the arrow keys (See Below)
- Practice often
- Take small steps (one command at a time)
My vim journey began 2 years ago when one of my subjects at university required us to ssh into a remote machine to do all our coding. I’d been coding for a while and I could work my way around the command line if I needed to but I was still very much in the comfortable world of the IDE. I’d traversed from Visual Studio on Windows to XCode on OSX and honestly I was happy. I could compile run debug and do all sorts of tricks with the press of a few buttons and for what I was doing it was more than enough.
My first vim experience probably like many others was the built in vim tutorial. I worked through it pretty slowly laughing at the concept of using letters to navigate the screen and wondering why anything needed such a complicated set of seemingly random commands. I printed my vim cheat sheet stuck it on the wall and got to work.
Progress was slow to say the least. I would never remember which commands performed which action and I had to set line numbers and a indenting rules every time I opened vim. I thought to myself, ‘There must be a better way’. Then I discovered the .vimrc
As I didn’t really know much about vim I figured I would find a .vimrc online that would solve all of my issues and use that. I read the description and it seemed to fit the bill with features above what I’d hoped for (you can use a mouse!) honestly looking back this was probably the biggest mistake I made, but an important one.
Copying the vimrc allowed me to code but the entire time I kind of felt like it was using vim for the sake of using vim. I got slightly faster by the end of the subject and I could use vim if I had to but my command set was entirely made up of the letter i, :wq and the arrow keys to move around the screen. The subject ended and with it my vim usage.
Back from the Dead
during the following 12 months I put an ssd in my laptop and decided rather than copy across all the seemingly useless stuff I would start from scratch and only install what I really needed. With that wipe (unbeknown to me) my seemingly precious copy of the same vimrc I used on the server was washed away into oblivion. Some time later I was perusing Hacker News and saw an article about vim. ‘Hell, why not’ I thought and decided to give the article and vim a chance.
I read that article on December 19 2011 (I know because my comment is on the article) and it was like the dirt was washed from my eyes. The article was Learn To Speak Vim by Yan Pritzker and after reading it I finally started to understand the value of the vim editor.
Text Do My Bidding (please)
Another thing I should probably mention is until about half way through 2012 I could not touch type. Everyone I knew seemed to learn at school but some how I managed to miss out. I could type fast enough for anything I needed to do but Vim without touch typing is about as useful as coding via Morse code. If you cannot touch type and want to use vim, stop right now and learn. I subjected myself to many online children’s touch typing games and whilst I’m still pretty average in terms of accuracy and speed I feel there is a definite improvement.
When I first reopened vim I noticed all my syntax highlighting and tab options had disappeared so I decided to remake a vimrc before I started getting seriously back into vim. I thankfully couldn’t find my old vimrc so I decided to write one from scratch. I looked online and saw that the :Set commands i was used to running fit easily into the vimrc and created a basic vimrc that highlighted syntax and used 4 space tabs.
Now honestly I didn’t use vim all that much for some time, I had textmate and XCode and never thought to open vim when I decided to code. Every now and then I would be working from the terminal for other reasons and it was most convenient. For one reason or another TextMate became somewhat of a pain for me to use (mainly because I could never remember any of the shortcuts) and I decided to get rid of it.
I told myself I would try and use vim whenever I could and the next big step forward came from adding four lines to my vimrc.
1 2 3 4
If you can do this and stick by it your vim productivity will increase significantly. It will be a pain to begin with I promise you that, make sure you know A appends after the end of the current line. You will be tempted to quit or use a mouse but it is worth it in the end.
From there it was just a matter of practice and slowly building up my command portfolio. If you can keep this up and learn a command every now and then you should be comfortable in vim in no time. In terms of commands if you find yourself doing something mundane over and over there is probably a command that can help you. Which commands you use often and in what order you learn them is defined by how you use vim don’t be afraid to experiment and go at your own pace.
To keep myself from rambling I’ll call it quits here. I’m no vim guru and I still type rather slowly but I’ve come to be comfortable working in vim and can see myself using it (perhaps not exclusively) in the future. If you know any great vim articles I should have a look at please let me know in a comment or an email.
- Elliot :)