sponsor Vim development Vim logo Vim Book Ad

files.vim : List files for partial search using 'ls' command

 script karma  Rating 7/4, Downloaded by 1633  Comments, bugs, improvements  Vim wiki

created by
Allen Kim
script type
Why another plugin?
I wanted open a file with by just typing a file name, even with a partial name of a file.
I found several plugins out there to find a file with a partial name.

    1) FuzzyFinder, http://www.vim.org/scripts/script.php?script_id=1984
    2) CtrlP, http://www.vim.org/scripts/script.php?script_id=3736
    3) Command-T. http://www.vim.org/scripts/script.php?script_id=3025

I tried all of them, and was not satisfactory.

All of the above tried to mimic other editors behavior, TextMate, and they are heavy(sometimes makes me wait to load files and expressions)

What I wanted was to see the files, and find what I want to open it. It is just simple combination of list and open, nothing else.
Futhermore, mimicing other IDE's command it not a vim's way in my opinion.

That's why I developed this plugin. It does;
  1. List all files(3 directory level deep)
  2. Let you find a file in a separate vim window
  3. Let you open a file in current or split window

How it works
  1. open a window and run result of run `ls` command (Sorry, window users)
  2. find your file name, `/`, then type <Enter> to open it

  To change the base directory of file list, run the vim command, :cd

  i.e. `:cd ~/myproject`.

  After :cd <path> command, your files listed by files.vim plugin will be based on the directory path.

created by
Allen Kim

script type

How it works

When initialized, set related files
In vim window, when n is pressed

1. Get the current file name
2. Get the related files
3. Open a window with related files and let you to choose which file to open
   1) <Enter> to open in a current window
   2) "o" to open in a horizontally splitted window
   3) "v" to open in a vertically split window

For Rails developers, there is pre-defined mapping like the following. You may want to change this. If so, you can re-define this in your .vimrc
    let g:nextFilesMap["Ruby On Rails"] = {
      \ "Ruby On Rails" : {
        \ "Controller" : { "expression" : "app/controllers/(.*)_controller.rb$", "transform" : "pluralize" },
        \ "Funtional Test" : { "expression" : "test/functional/(.*)_controller_test.rb$", "transform" : "pluralize" },
        \ "View" : { "expression" : "app/views/(.*)/", "transform" : "pluralize" },
        \ "Model" : { "expression" : "app/models/(.*).rb$", "transform" : "singularize" },
        \ "Unit Test" : { "expression" : "test/unit/(.*)_test.rb$", "transform" : "singularize" }
      \ }
    \ }

For screenshot and source code, visit https://github.com/bighostkim/files.vim,
and if you want to make this better, please log an issue or fork this repository.
install details
  1. Download files.vim into your ~/.vim/plugin directory
  2. in ~/.vimrc, add a key map to call Files() function, I prefer \f, but you can choose any you want.
    nmap <Leader>f <ESC>:call Files()<CR>

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
files.vim 0.2 2013-09-09 7.0 Allen Kim Added help line on the top
files.vim 0.1 2013-09-09 7.0 Allen Kim Initial upload
ip used for rating:

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.
Vim at Github