Improving Vim Speed

A grab-bag of tips to speed up your vimming! ctrlp command-t rails.vim surround.vim Ben's vim talk at Railsberry
This is a companion discussion topic for the original entry at

Learning VIM is it helpful, harmful or irrelevant to use a GUI wrapper like Macvim or gVim?

I bought VIM Adventures subscription. And I just keep playing the game over n over again. Very good decision in terms of pracitising vim.

Anyone have best practice for installing vim on yosemite?

brew install vim, or copy ‘mvim’ from MacVim package contents, for example?

I’ve got a fresh install here and I want to make sure I get it right. My command-t stopped working after an upgrade.

@Joe_Sak Most of my build tools broke when I upgraded to Yosemite beta this week. Command-T has a C-extension that has to get compiled locally, so I’d advocate uninstalling it (Command-T) and reinstalling it, but first make sure that you can build C extensions by installing a Homebrew formula or Ruby gem that requires an extension (something like Nokogiri).

I had to install Xcode Beta 6 and the related command line tools because Yosemite doesn’t work very well with the general release Xcode at the current time.

For what it’s worth, here is the best way to get vim working

  • install latest xcode (currently 6.1 beta 2 for Yosemite)
  • use homebrew
  • make sure you’re on system ruby
  • brew install vim
  • follow command-t installation

Basically, vim and command-t must both be compiled on system ruby

Glad you got it working. For users of rbenv whose shims are in use even for non-login shells, you may actually have to be sure that everything’s compiled in your non-system Ruby, but that’s very good to know that consistency is a factor in whether or not it works.

I’ve got a few things I’ve found over the last few mos that have really helped me. One is renaming a file in vim with :Rename written by Gary Bernhardt which will rename the current file and rm the previous one:

function! RenameFile()
  let old_name = expand('%')
  let new_name = input('New file name: ', expand('%'))
  if new_name != '' && new_name != old_name
    exec ':saveas ' . new_name
    exec ':silent !rm ' . old_name
map <leader>n :call RenameFile()<cr>

This one is just a pet peeve of mine but I hate seeing trailing white space so I use this:

" remove trailing white space
autocmd BufWritePre * :%s/\s\+$//e

I believe this one is in the Thoughtbot dot files but it’s made TDD really fast for me - that is changing to the last file you were in:

"move to last file
nnoremap <leader><leader> <c-^>

@Anthony_Ross, Gary Bernhardt’s script is awesome, I used that for the last year. A couple weeks ago I simplified using vim-eunuch, whose :Move command functions in a similar way. Now I can move/rename a file with <leader>m like this:

nnoremap <Leader>m :Move <C-r>%

The <C-r>% inserts the current file name in the command line in much the same way that Gary’s script did. I think functionally these two approaches are really similar, but using vim-eunuch meant fewer lines in my personal config.

1 Like

@benorenstein what font are you using in your terminal settings?

Monaco 10 pt

Thanks. I thought the font in the videos may have been a custom font. I ended up settling on consolas 13pt :slight_smile:

Thanks for the tip on Hard mode, exactly what I need