About 18 months ago I made the decision to give Vim a go as my primary text editor. I had been using vi extensively for server admin work for a number of years so I wasn’t a total noob. TextMate was my default editor and broadly I was happy with it but decided to give Vim a go.
I started out with baby steps, looking back to TextMate and doing all of the common things a switcher does, especially looking for TextMate’s features in Vim. Vim’s contexts were familiar to me from working on servers so I was at an advantage there but I quickly found Derek Wyatt’s awesome video series on Vim. Derek’s videos were one of the main reasons my adoption was so positive. If you are thinking of switching to Vim I strongly recommend this resource. The videos start at a beginner level and work through to advanced techniques, are excellently produced and give a particular helping hand for newcomers. If you’ve never used Vim the Welcome to Vim video is the best.
Many people recommend using MacVim to ease the transition. Henrik Nyh has a great article on switching from TextMate using MacVim. I didn’t follow this route but it may be helpful to some.
Installation of MacVim via homebrew on OSX is easy
brew install macvim
MacVim works like a standard application so you don’t need to edit directly in the terminal and comes with many common keyboard shortcuts that you’ll likely be used to.
As with with many things in UNIX you get back what you put in. The RTFM mantra is true for Vim - it has massive and excellent documentation that you could spend months going through. The default install of Vim needs to be configured which takes time. Initially I scoured github for dotfiles and basically took configuration from developers that I admire - Tim Pope and Mislav Marohnić. I tweaked a little here and there, marrying up a color scheme with my terminal color scheme of choice ir_black. If you want to pick through my dotfiles they are here.
Pretty much after that I had a text editor that looked good, had sensible defaults for web programming and recognised the file formats I was editing. Then came the hard bit - getting to intermediate level.
Vim does take time to learn. Initially it would be fair to say that I became slower. Probably for around a month. But as you go you quickly learn how Vim works and are delighted by the time-saving over other editors in almost every feature. Learning to stop using the mouse is a paradigm shift but one I highly recommend. When you get to a stage where you can quickly split windows and navigate round without using a mouse you’ll see the light. I challenge anyone to commit Vim’s many commands to muscle memory but the more you work with Vim the more it becomes automatic and that’s where Vim’s power lies.
My tip is to take a little at a time and when you come up against a common problem read the manual and learn how to do. For example you might want to lowercase some text. You could do this through deleting the text and rewriting it or you could you use Vim’s excellent help to learn how Vim does it:
This takes you straight to the documentation where you can learn the keystrokes that Vim uses before doing it in a split window context. Typically it takes me four or five lookups before I remember what the keystrokes are. If I ever forget looking it up again in the help text is so easy it is not an issue.
Around about the time I was moving from a novice to intermediate Vim user Vimcasts arrived on the scene. Drew Neil produces high quality screencasts on all aspects of using Vim and I highly recommend this resource. A book is also apparently in the offing from this sage so stay tuned for more from Drew.
The more you use Vim the more you build on your muscle memory. More and more I’m finding I consult the documentation less and just do it. In short I’m starting to feel like I’m over the hump and am seeing the many benefits of the learning stage. But it would be fair to say that I had to pump a lot of iron to get to this stage. Months 6 - 12 were a big learning curve in that respect, and I’m still learning all the time. I don’t feel I’ll ever learn everything about Vim but I now feel I’m at a stage where I know how to get better.
Fast forward 18 months and I feel I would be significantly less productive without using Vim not just for coding but also for text editing. So I can use vim for writing emails I now use Mutt, a lightweight powerful email client for the terminal. I use the Vimium extension for Chromium, and of course Vim for all of my coding. The experiment has been an extremely happy one for me.
I accept that Vim is not for everyone. Casual coders, or anyone who doesn’t want to get their hands dirty should probably stick with TextMate. Yahuda Katz famously blogged that switching to Vim was not easy and I accept many of his points. Vim isn’t going to be something you can pick up and use straightaway.
But if you stick with it you might just see the light. I did and can only give Vim a massive ringing endorsement.
Have an update or suggestion for this article? You can edit it here and send me a pull request.
Using HashiCorp Vault with LDAP
How to use HashiCorp Vault to setup an LDAP backed secret store with read-only access for users in groups and read-write access for specific users
Linux and Unix xargs command tutorial with examples
Tutorial on using xargs, a UNIX and Linux command for building and executing command lines from standard input. Examples of cutting by character, byte position, cutting based on delimiter and how to modify the output delimiter.
Copy a file in Go
How to copy a file in Go. The ioutil package does not offer a shorthand way of copying a file. Instead the os package should be used.