of.vim : Switch between open files / Find files by parital name (Similar to TM's Cmd-T)
| script karma
Downloaded by 827
Comments, bugs, improvements
script versions (upload new version)
|This script works under CLI Vim (not gvim) and provides a curses interface for switching between / opening files simlar to TextMate's Cmd-T command. It requires Vim to be compiled with Ruby bindings, and if you want it to keep a history, also for Ruby's sqlite3 bindings to be installed (it makes a db in your home directory, .of.db, where it stores info on recently opened files and preferred shortcuts for certain files). To open a file called accounts_controller.php, you could simply call OF (I bind it to Alt-T) and type in ac -- a list of files under your working directory come up that have these two letters in any order. Move up and down with arrows or ^P/^N, scroll with your mouse, or click/enter to select. Escape gets you out. This is a work in progress. The code has no comments and needs to be cleaned up, but it does what I want it to for now, and maybe what you want.
This may be a little slow if run from a directory with a huge amount of files. I usually start it from the base of whatever project I'm working on.
|Make sure you have Ruby bindings compiled into Vim. They are included in Ubuntu's vim-full package, and can be compiled in with the --enable-rubyinterp option for ./configure if you are compiling from source. To check if they're working in Vim, type :ruby puts 'Hello'.
If you want a working file history, and smart reuse of the shortcuts you use, you'll also need to install Ruby, Sqlite3 and Ruby Sqlite3 bindings on your system (highly recommended, but a pain on some systems):
sudo apt-get install vim-full ruby libsqlite3-ruby sqlite3 (easy as pie)
sudo yum install ruby-devel
sudo yum install sqlite3-devel
sudo gem install sqlite3-ruby (there is probably a yum package for ruby-sqlite3, but there wasn't on the machine I tested on)
OS X via MacPorts: (with /opt/local/bin in your path before /usr/bin):
sudo port install ruby
sudo port install vim +ruby
sudo port install sqlite3
sudo port install rb-rubygems
sudo gem update
sudo gem install sqlite3-ruby
Put of.vim in your ~/.vim/plugins folder, and bind call OF() to something. I use Alt-T (in my .vimrc):
nnoremap ^[t :call OF()<CR>
(type ^[t like ctrl-v, alt-t)
If you need to do anything special to install it on another type of system, shoot me an email and I will post the details here.
Click on the package to download.
ip used for rating: 18.104.22.168