I really love TextMate. It’s very possibly the best editor available on OS X. At the same time though, I’ve started doing more and more work in the shell and on remote systems where TextMate isn’t available. I needed an editor that was cross-platform; something that presented a uniform interface across different machines. In the halcyon days of high school, I used
vi, and then
I figured it was time to see how much I remembered.
The first thing I did was to install NERD Tree. This provides a handy file browser that I can toggle off and on at will. A screen shot:
I’ve mapped a command with my leader1 to toggle the tree:
map <Leader>, :NERDTreeToggle<cr>
This means I can simply press
I constantly used Apple-1, Apple-2, Apple-N to switch between tabs in TextMate. I rarely used the next/previous tab commands. I found going directly to the tab I needed was much quicker.
MacVim doesn’t have default keybindings for switching to tabs directly, but with some help from the MacVim mailing list, the following .gvimrc mappings work perfectly:
map <D-1> :tabn 1<CR> map <D-2> :tabn 2<CR> map <D-3> :tabn 3<CR> map <D-4> :tabn 4<CR> map <D-5> :tabn 5<CR> map <D-6> :tabn 6<CR> map <D-7> :tabn 7<CR> map <D-8> :tabn 8<CR> map <D-9> :tabn 9<CR> map! <D-1> <C-O>:tabn 1<CR> map! <D-2> <C-O>:tabn 2<CR> map! <D-3> <C-O>:tabn 3<CR> map! <D-4> <C-O>:tabn 4<CR> map! <D-5> <C-O>:tabn 5<CR> map! <D-6> <C-O>:tabn 6<CR> map! <D-7> <C-O>:tabn 7<CR> map! <D-8> <C-O>:tabn 8<CR> map! <D-9> <C-O>:tabn 9<CR>
The first set is to bind the keys in command mode. The second is to bind the keys in insert mode.
I have various bits and pieces of config that alters options to better match what I need, such as softtabs in lieu of hard tabs, 4-space indents, and line numbers.
In .gvimrc, I’ve also set the default font to be Monaco 12. I’ve grown up with Monaco, and it always feels weird to code without it:
I also tend to run into files where there’s a mix of Windows and Unix line-endings. It’s a pain in the ass, since Vim will will show the ^M line-endings. A quick search and replace works wonders:
map <Leader>m mz:%s/\r$//g<cr>`z
My complete vim config is at media.nodnod.net/vimrc.txt.
A ‘leader’ is typically a prefix keystroke to capture in a personal namespace all the random personal commands one is likely to have. In my case, it is set to comma.↩
Indeed, it makes pretty clear where its inspiration originates.↩
Which I’ve slightly modified. I took out outline:0 on :focus, for example, because I never remembered to restyle them, and the default behavior removes a fairly critical piece of expected UI response. I also have clearfix as part of my standard css init snippet.↩