From 07c883a5418028bbb48b38d6a2cf86d011de4b1b Mon Sep 17 00:00:00 2001 From: Stefan Huber Date: Sat, 18 Dec 2021 20:22:05 +0100 Subject: [PATCH] keymaps: Smart vsplit direction for fsswitch --- keymaps.vim | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) 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 -- 2.39.5