Six months using Vim
I have spent the last 6 months on a project where we are using Vim as the editor of choice. Before starting on this project my only experience with Vim was a brief stint during University so I was mostly a Vim newbie.
My Verdict
So after using Vim for 6 months I can honestly says it’s amazingly fast. No other editor I’ve used comes close. Sure Vim has been around forever, but for modifying text you simply can’t beat it. I definitely didn’t realize how much of my time I spend simply navigating and modifying existing code (I would guess 70-80% of the time) and this is where Vim really shines. Your hands pretty much never leave the keyboard while navigating between files and all the different shortcuts makes the actual editing lightning fast.
To put things in perspective, after 2 weeks of using Vim I wanted to do some coding on my laptop. I bought my own copy of TextMate specifically for Rails development (I especially like having the navigation pane on the side), so as usual I started coding away in TextMate. About 5 minutes later I was downloading MacVim and I don’t think I’ve used TextMate since – any other editor simply makes it feel like you’re crawling along.
One definite negative with Vim is the steep learning curve. I was lucky enough to be pairing every day, which means you’re basically sitting next to a Vim expert every step of the way. Even so it was very painful at first – it simply takes a while before the different commands become intuitive.
I’ve you’ve been toying with the idea of trying Vim I would highly recommend that you go ahead and take the plunge. Trust me – you won’t look back.
My favorite shortcuts
I thought it would be a fun excercise to list all my favorite shortcuts, so here we go. Apart from the usual h,j,k,l navigation, I mostly use:
- w or b – navigate to the next or previous word
- W or B – navigate to the next or previous word after a whitespace
- [ or ] – navigate to the next or previous paragraph (empty line)
- 0 or $ – navigate to the beginning or end of the current line
- gg or G – navigate to the beginning or end of the current document
- i or Shift+i – insert before the cursor or at the beginning of the line
- a or Shift+a – insert after the cursor or at the end of the line
- o or Shift+o – add a new line after or before the current line
- y – yank the selected text
- yy – yank the current line
- yw – yank from the cursor to the end of current word
- yiw – yank the word the cursor is currently in
- d – cut the selected text
- dd – cut the current line
- dw – cut from the cursor to the end of the current word
- diw – cut the word the cursor is currently in
- d$ – cut from the cursor to the end of the current line
- p or Shift+p – paste after or before the current cursor
- Shift+j – Join the current line and the next line
- . – repeat the last action (this one is really great!)
- < or > – indent the current selection
- =,Shift+g – format from the current line to the end of the document
Apart from this there is all the usual visual mode and regex shortcuts (which aren’t anything special). I probably left out a ton, but these are all the ones I could think of for the moment. Happy coding.