Switching editors - revisited

March 12, 2015

A couple of weeks ago, I wrote a little about switching editors and my plan to use Vim for all my editing tasks for (at least) a few weeks.

Well, a few weeks have passed, and it’s time to report back. Am I still using Vim? Yes, I am. It took a little getting used to, and especially the first few days I even resorted to using SublimeText for a few chores because Vim was too frustrating at that point.

Does that mean Vim is a bad editor? No, it’s just an acquired taste, and I am still acquiring it. The trick is adapting Vim to your needs, wants and habits, and unfortunately that takes a lot of time, and a lot of effort. But I do believe it will be worth it.

Using Vim on OSX

My previous ‘daily drivers’ were graphical editors, and Vim, in its essence, is not a graphical editor. Right out of the box it doesn’t play nice with mouse selection or the clipboard, it doesn’t offer a tree-view of your files and directories, much less offer tabs for your open files.

MacVim

One of the ways of getting Vim to behave more like a graphical editor, is installing MacVim. The easiest way to get MacVim is installing it via Homebrew:

$ brew install macvim

MacVim gives you Vim in a graphical OSX window, with menus and stuff like that. But in its essence, it’s still plain Vim.

VimR

A second option I came across recently is a new project called ‘Vim Refined’, or VimR. VimR offers a sidebar with a tree-view of your files, has tabs for your open files, has ‘fuzzy file find’ and is extensible via plugins. At first glance, VimR is pretty awesome, although things will get messy if you’re used to using tabs, windows and buffers within ‘non-graphical’ Vim, as the tab implementation in VimR doesn’t play nice with any of those.

No GUI

The third option is properly configuring your non-graphical Vim, so it has proper mouse support, has a tree-view, and plays nice with your clipboard. Most of this is achieved by building a proper .vimrc and adding a few plugins, but fixing the clipboard means getting Vim from Homebrew, as the version of Vim that is shipped with OSX Yosemite is broken.

$ brew install vim

After installing Vim, you need to make sure you either rename/remove the ‘system Vim’ or have /usr/local/bin before /usr/bin in your PATH variable.

Vim, improved configuration

I am still improving my Vim configuration as I go along, but a few things have already made my life (in Vim) much, much easier.

  • Vundle: Vundle is a plugin management system for Vim, saves you all the hassle of installing or updating plugins.
  • Mouse mode: by using set mouse=a inside my .vimrc I can actually select text with my mouse without also selecting the line numbers. I can also scroll through my files using the mouse.
  • Proper backspace: by using set backspace=2, the backspace key behaves as it would in any other text editor, instead of ‘Vim mode’ that probably makes a lot of sense to some, but not to me. Yay for free choice.
  • OSX Clipboard: by installing Vim through Homebrew and setting set clipboard=unnamed I can actually copy to and paste from the OSX clipboard.
  • Powerline: Powerline adds a highly functional status bar to your Vim.
  • Nerdtree: Nerdtree adds a sidebar with a file-browser, which you can toggle on or off. If you’re used to an editor like Sublime, this is a must-have.
  • Fugitive: Git commit, diff, blame, etcetera, all within Vim.
  • Syntastic: a highly configurable syntax checker within Vim.

Using git for your dotfiles

I have put all my important ‘dotfiles’ inside a Git repository so I can easily set up any Mac or Linux machine to work the way I want it to. Just clone the repository and run install.sh and everything will be set up; Liquidprompt, Bash config, Vim, Screen, etcetera.

I will further show how this works in another blog post.

For now, I am mostly content with my switch from Sublime to Vim, and I recommend everyone to at least give it a shot. Just don’t give up too soon ;-)