sponsor Vim development Vim logo Vim Book Ad

of.vim : Switch between open files / Find files by parital name (Similar to TM's Cmd-T)

 script karma  Rating 74/21, Downloaded by 785    Comments, bugs, improvements  Vim wiki

created by
Ethan McCreadie
 
script type
utility
 
description
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.
 
install details
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):

In Ubuntu:

sudo apt-get install vim-full ruby libsqlite3-ruby sqlite3  (easy as pie)

Via Yum:

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.
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
of.vim 0.16 2007-10-15 7.0 Ethan McCreadie adjusted scrolling and file-list caching
of.vim 0.15 2007-10-15 7.0 Ethan McCreadie fixed scrolling issue and some funky db saves
of.vim 0.14 2007-10-12 7.0 Ethan McCreadie fixes
of.vim 0.13 2007-10-12 7.0 Ethan McCreadie Allows script to function without sqlite support.  Much more fun if you have it though.
of.vim 0.12 2007-10-12 6.0 Ethan McCreadie Accomodates for versions of sqlite that don't support CREATE TABLE IF NOT EXISTS syntax
of.vim 0.11 2007-10-12 6.0 Ethan McCreadie Allows for sqlite3 to come from ruby-gems, fixed minor bugs.
of.vim 0.1 2007-10-12 7.0 Ethan McCreadie Initial upload
ip used for rating: 54.211.180.175

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
SourceForge.net Logo