Ⅰ. 插件描述
Vim plugin that makes it trivial to jump between alternate files (test files & implementation, etc.)Ⅱ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'cyphactor/vim-open-alternate'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'cyphactor/vim-open-alternate'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'cyphactor/vim-open-alternate'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/cyphactor/vim-open-alternate
Ⅳ. 文档说明
open-alternate.vim
Note: This project is no longer maintained. Please see my new project
alt that provides the same type of
functionality in a more general way.
Bringing alternate file opening to the forefront
What it provides?
This plugin provides a simple solution for opening alternate files
intelligently in vim. It does this by providing a
user-command called OpenAlternate which when executed will open the
alternate file to the currently opened file.
Supported File Types
Currently, this plugin supports the following list of file types.
| Current File | Alternate File |
|---|---|
| RSpec File | Ruby Implementation file (includes logic for Hanami and Ruby on Rails) |
| Ruby Implementation File | RSpec file (includes logic for Hanami and Ruby on Rails) |
| Cucumber Feature File | Cucumber Step Definition file |
| Cucumber Step Definition File | Cucumber Feature file |
| Rails Rake File | Rails Rake Spec file |
| Elixir ExUnit File | Elixir Module Implementation File |
| Elixir Module Implementation File | Elixir ExUnit File |
Installation
If you don't have a preferred installation method, I recommend installing
pathogen.vim and using it in
combination with [git
submodules](http://git-scm.com/book/en/Git-Tools-Submodules) as describe in
this [Vimcast - Synchronizing plugins with git submodules and
pathogen](http://vimcasts.org/episodes/synchronizing-plugins-with-git-submodules-and-pathogen/).
If your installation method is the above recommended one, it should be as
simple as running the following commands:
cd ~/.vim/
git submodule add git@github.com:cyphactor/vim-open-alternate.git bundle/vim-open-alternate
git add .
git commit -m "Added vim-open-alternate plugin to my setup."
If you're using Janus it's very similar, just omit the bundle directory:
cd ~/.janus/
git submodule add git@github.com:cyphactor/vim-open-alternate.git vim-open-alternate
git add .
git commit -m "Added vim-open-alternate plugin to my setup."
If you are using another method, you are on your own. I have been told that
this plugin is compatible with Vundle
but I have not tested it myself.
Configuration
The recommended configuration for this plugin is to simply map a key combo to
run the OpenAlternate command for you. This can easily be done by adding the
following to your ~/.vimrc.
nnoremap <leader>. :OpenAlternate<cr>
In the above example I map my normal mode <leader>. key combo to execute theOpenAlternate command, in turn opening the alternate file for editing.
You can of course map this command anyway you like, or even choose not to map
it and just execute the command as follows when you need it.
:OpenAlternate<cr>
Credits
I took the idea for my <leader>. binding and some logic for opening the
alternate file from Gary Bernhardt's vim setup. I also took bits and pieces of
file path conversions for alternate files from numerios friends .vimrc
- Therefore, credit must go out to Gary Bernhardt for a reasonable
- point as well as my numerous friends for sharing their alternate
file path conversions with me.
License
Copyright (c) Andrew De Ponte. Distributed under the same terms as Vim itself.
See :help license.
