vim-swapfiles uses user defined list of patterns to cycle between files in VIM.
This helps in programming languages like C++ to cycle between source and header files.
If you have src/somefile.cpp currently opened in VIM buffer and next variable defined in .vimrc
let g:swap_files_groups = [['src/{}.cpp', 'include/{}.h']]calling function in VIM command line
:SwapFileswill open new/existing buffer with include/somefile.h, if file exists.
Calling the SwapFiles again will open src/somefile.cpp.
Set g:swap_files_groups to define patterns.
{} is a wildcard for filename.
let g:swap_files_groups = [['src/{}.cpp', 'include/{}.h'], ['{}.cuh', '{}.cu']]Call :SwapFiles to cycle between files.
VIM needs to support python3. Check the output of the :version to verify.
- Add next line into
.vimrc
Plug 'tdakhran/vim-swapfiles'- Execute
vim +PlugInstall +qall
let g:swap_files_groups = [['src/{}.cpp', 'include/{}.h']]