Cool MacVim Additions to My .vimrc
I've been using MacVim for a while and it's really quite amazing. It's Vim as nice as Vim ever was, but it's also a complete Mac app with multiple windows, tabs, toolbar - everything you'd expect from a Mac app. It's really quite amazing.
That said, I've been fiddling with the .vimrc file to try to get it to do a few interesting things. I just thought I'd post them so that if I needed to look them up, I'd have them written down.
Switching Tabs
One of the nice things someone suggested was the ability for Cmd-1, Cmd-2, etc. to move to tab 1, 2, etc. like Firefox does. Cool! I thought, as this will keep my hands on the keyboard even more. The remapping of the key is really two parts: what key combination to use, and what to remap to it? The first answer is that <D-1>, <D-2>, etc. for Cmd-1, Cmd-2, etc. The second part os the command :tabn. Together, these fit into the .vimrc like:
if (has("gui_macvim")) :nnoremap:tabn 1 :nnoremap :tabn 2 :nnoremap :tabn 3 :nnoremap :tabn 4 :nnoremap :tabn 5 :nnoremap :tabn 6 endif
Decent Colors
I know it seems silly, but I've really become used to the colors I've used in Vim over the years. They are called the 'torte' color scheme, and even that's not 100% - the cursor and search colors aren't really right, so I fix them up as well:
if (has("gui_macvim")) :colorscheme torte :hi Cursor guibg=red :hi Search guibg=orange endif
Setting the Tab Name and Current Directory
I wanted just the filename in the tab and not the complete path - even truncated. Also, with a simple autocmd I can make it so that every time I change the buffer (file) I will make the current working directory the directory of the file in that buffer. It's an easy way to make sure that it's easy to add other files from the same directory.
if (has("gui_macvim")) :autocmd BufEnter * :cd %:p:h :set guitablabel=%t endif
None of these are really earth-shaking, but they do make it a lot nicer to use Vim, and it's amazing that they are all very simple configuration file changes. Amazing tool Vim, and what they've done with it for MacVim.