A vim plugin for opening a related file based on the file path.
I prefer to use Vundle but it's just as easy using other methods.
Install Vundle, following the instructions.
Add the Bundle to your vimrc:
Then run the
BundleInstall from the command line:
vim +BundleInstall +qall
If you use pathogen.vim, you can just clone the repo, manually.
git clone https://github.com/donaldducky/related.vim ~/.vim/bundle/related.vim
There are two commands currently exposed:
:RelatedFile- Opens the related file in a vertical split. Optionally accepts an argument to open the related file using other methods:
:RelatedFile eopens using
:e[dit]command in the current window
:RelatedFile spopens using
:sp[lit]command in a horizontal split window
:RelatedFile vsopens using
:vs[plit]command in a vertical split window
:RelatedTests- Runs the unit tests for the plugin.
- Open a source file.
- Hit a key to open the related test file.
I bind the
:RelatedFile command to a
<leader> mapping in my
" Open the related file using ,rf let mapleader = "," let g:mapleader = "," map <Leader>rf :RelatedFile<CR> map <Leader>re :RelatedFile e<CR> map <Leader>rs :RelatedFile sp<CR>
I spend far too much time navigating/opening related files that are easy to determine programmatically.
Creating a vim plugin would be the best way to do it but I didn't know how...luckily I stumbled across a post that was created to achieve the same thing:
It was a good basis for showing me how to create a vim plugin and seeing how little code it was made me dive in.