vim-fswitch icon indicating copy to clipboard operation
vim-fswitch copied to clipboard

Header always above

Open galou opened this issue 6 years ago • 1 comments

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

galou avatar Nov 01 '19 13:11 galou

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.

galou avatar Nov 07 '19 07:11 galou