vim-fswitch
vim-fswitch copied to clipboard
Header always above
Thanks for this plugin, I just installed it but it looks very good from the first tries I gave to it (your plugin looked the most interesting from the list there).
I have a question though. Is there a possibility to always open the header file in the split window above and the source file in the split window below?
Use cases:
- From header in single window --> open source in split window below and switch to it.
- From source in single window --> open source in split window above and switch to it.
- From header in split window --> switch to window where the source already was, i.e. below.
- From source in split window --> switch to window where the header already was, i.e. above.
Thanks! Gaël
I wrote something myself:
function! s:fs_header_above()
let ext = expand('%:e')
if winnr('$') == 1
" If there is only one window.
" TODO: detect only the number of horizontal splits.
if ext == 'h' || ext == 'hpp'
FSSplitBelow
else
FSSplitAbove
endif
else
if ext == 'h' || ext == 'hpp'
FSBelow
else
FSAbove
endif
endif
endfunction
command! FSHeaderAbove call s:fs_header_above()
It's not perfect because it won't work if there is a vertical split.