Enabling your mouse for use in Vim might be sacrilegious, but damnit it's helpful
TLDR; To enable vim to recognize mouse commands on a mac
1. Install install SIMBL
2. Drop the following in your .vimrc
3. Restart your terminal
set mouse=a " tell vim to recognize mouse commands in "all" modes
set ttymouse=xterm2 " tell vim you're using xterm, this isn't necessary but I believe improves performance
set ttyfast " improve fluidity of mouse commands, this isn't necessary but I believe improves performance
set paste " don't mess up the indenting of pasted text
vmap <C-C> "+y " map ctrl-c to copy a block of text selected by the mouse
I've been trying to commit to Vim full-time, but almost all of the projects I've worked on are rails projects which become bloated with files and directories. Therefore, navigation becomes my biggest pain point. GUI-based navigation is especially important when joining a new project where you don't know where anything is. Because of this, Sublime has been my go-to with its easy to use file tree, file finder, and project-based search preview being the difference makers.
So to solve this problem in Vim, I started using fuzzy search (cirl-p), NERDTree for file navigation, and lastly enabling my mouse for scrolling through files, copy-pasting, and clicking NERDTree nav. However, getting my mouse to work with iTerm and vim on a mac wasn't as intuitive as I thought.
This wasn't really an issue until recently when I needed to debug a gem in my VM, but bundle open <GEM-NAME>
opened a blank vi editor without any vim configuration. I wanted to use my dotfiles on my VM so I wrote an ansible script to configure vim on my VM.
First, you got to install SIMBL
Next, you have to enable vim to recognize mouse commands.
set mouse=a " tell vim to recognize mouse commands in "all" modes
set ttymouse=xterm2 " tell vim you're using xterm, this isn't necessary but I believe improves performance
set ttyfast " improve fluidity of mouse commands, this isn't necessary but I believe improves performance
set paste " don't mess up the indenting of pasted text
vmap <C-C> "+y " map ctrl-c to copy a block of text selected by the mouse
Let's check this out in action:
Note: I use thoughtbot's dotfiles for managing my dotfiles. I also use a Vagrant and ansible at work to streamline working in groups and managing dependencies.