Skip to content
Switch to related files
Vim script
Branch: master
Clone or download
Latest commit 9a36bc1 Oct 30, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
autoload Ensure the buffer has a name Oct 26, 2019
ftplugin Use lambda Oct 30, 2019
LICENSE Hello, world! Oct 25, 2019
README.markdown Add callbacks with switchy#add() Oct 26, 2019

README.markdown

Switch to related files.

Usage: map switchy#switch() to something, for example:

nnoremap <Leader>a :call switchy#switch('split', 'sbuf')<CR>

command! Switch call switchy#switch('split', 'sbuf')

The first function argument is the command to use when editing a file (e.g. edit, split, tabedit, sbuf, etc.), the second argument is the command to use when the buffer is already loaded. This is useful to switch to an existing split/tab instead of opening a new one.

You can add your own callbacks with switchy#add(); see ftplugin/go.vim for an example.


Supported filetypes:

  • Go: a.goa_test.go

Yeah, it's early days for this plugin. More filetypes soon™


Survey of existing methods:

  • a.vim: Too many commands, only supports C/C++ out of the box.

  • FSwitch: Too many commands, only supports C/C++ out of the box.

  • vim-altr: Doesn't load buffer if file doesn't exist, don't like the code (tried to patch this).

  • alternate-lite: Needs lh-vim-lib, too many commands.

  • unimpaired.vim: Kinda works, not really intended for this and can't create new file easily.

  • Manual:

    :e %<.c
    nnoremap <F4> :e %:p:s,.h$,.X123X,:s,.cpp$,.h,:s,.X123X$,.cpp,<CR>
    

    It's okay, but not as fast as e.g. <Leader>a, also not flexible to multiple filetypes etc.

You can’t perform that action at this time.