From: Stefan Huber Date: Sat, 18 Dec 2021 19:22:05 +0000 (+0100) Subject: keymaps: Smart vsplit direction for fsswitch X-Git-Url: https://git.sthu.org/?p=vimconf.git;a=commitdiff_plain;h=07c883a5418028bbb48b38d6a2cf86d011de4b1b keymaps: Smart vsplit direction for fsswitch --- diff --git a/keymaps.vim b/keymaps.vim index 4569a4a..bc6f51d 100644 --- a/keymaps.vim +++ b/keymaps.vim @@ -39,7 +39,20 @@ nmap ga (EasyAlign) au Filetype gnuplot map :call OpenIn("gnuplot -persist") -au Filetype c,cpp,objc map :vsplit:FSRight +" Performs a vertial split and a FSHere. For a header file the split is +" performed to the left, for an implementation file to the right. +function FSvsplit() + " We split to the right on header files + if match(expand('%:e'), 'h.*') >= 0 + execute ':leftabove vsplit' + else + execute ':rightbelow vsplit' + endif + + execute ':FSHere' +endfunction + +au Filetype c,cpp,objc map :call FSvsplit() " Terminal-based vi report S-F11 as F23 au Filetype c,cpp,objc map :FSHere au Filetype c,cpp,objc map :FSHere