sponsor Vim development Vim logo Vim Book Ad

nextfile.vim : Vim plugin to open related files by key(i.e. \n or any)

 script karma  Rating 24/6, Downloaded by 2793  Comments, bugs, improvements  Vim wiki

created by
Allen Kim
 
script type
utility
 
description
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/nextfile.vim,
and if you want to make this better, please log an issue or fork this repository.

If you like this, you may like files.vim also,  https://github.com/bighostkim/files.vim.
 
install details
Install it with Vundle
  
    Bundle 'bighostkim/nextfile.vim'

Or, download the following files into ~/.vim/plugin directory. Two .txt files, singular_expressions.txt and plural_expressoins.txt, are used to convert file names into singular and plural word in English.

. nextfile.vim
. singular_expressions.txt
. plural_expressions.txt

To your ~/.vimrc, add a keyboard map to call NextFile() function

    nmap <Leader>n <ESC>:call NextFile()<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
nextfile.vim.zip 0.4 2013-09-17 7.0 Allen Kim Open/Close directory by <Enter>
nextfile.vim.zip 0.3 2013-09-09 7.0 Allen Kim help line one the top, most related file on the next line with cursor
nextfile.vim.zip 0.2 2013-09-05 7.0 Allen Kim changed file switching to file browser so that we can open by split or vsplit
nextfile.vim 0.1 2013-08-18 7.0 Allen Kim Initial upload
ip used for rating: 18.97.9.171

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