Skip to content

arp242/switchy.vim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Switch to related files.

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

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

Or use a command if you prefer:

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 (note you must have switchbuf set to useopen or usetab to switch to an already open window or tab, otherwise it will create a new window).

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


Supported filetypes:

c       a.c   ⇄  a.h
cpp     a.cpp ⇄  a.h or a.hpp
go      a.go  ⇄  a_test.go
nim     a.nim ⇄  test_a.nim
python  a.py  ⇄  tests/test_a.py

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 for multiple filetypes.

About

Switch to related files

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Contributors 3

  •  
  •  
  •