From 5315ee88d093a8e4d6883cfc2748562ff542fd72 Mon Sep 17 00:00:00 2001 From: Jim Riordan Date: Wed, 17 Jun 2015 11:41:04 +1000 Subject: [PATCH] Allow easy opening of spf13-vim config files ev is mapped to a function that opens the following files in a new tab .vimrc .vimrc.before .vimrc.bundles .vimrc.local .vimrc.before.local .vimrc.bundles.local .vimrc.fork .vimrc.before.fork .vimrc.bundles.fork sv is mapped to a function that reloads the spf13 config --- .vimrc | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/.vimrc b/.vimrc index 050238b..58f8f6e 100644 --- a/.vimrc +++ b/.vimrc @@ -1150,6 +1150,48 @@ " e.g. Grep current file for : Shell grep -Hn % " } + function! s:IsSpf13Fork() + let s:is_fork = 0 + let s:fork_files = ["~/.vimrc.fork", "~/.vimrc.before.fork", "~/.vimrc.bundles.fork"] + for fork_file in s:fork_files + if filereadable(expand(fork_file, ":p")) + let s:is_fork = 1 + break + endif + endfor + return s:is_fork + endfunction + + function! s:ExpandFilenameAndExecute(command, file) + execute a:command . " " . expand(a:file, ":p") + endfunction + + function! s:EditSpf13Config() + call ExpandFilenameAndExecute("tabedit", "~/.vimrc") + call ExpandFilenameAndExecute("vsplit", "~/.vimrc.before") + call ExpandFilenameAndExecute("vsplit", "~/.vimrc.bundles") + + execute bufwinnr(".vimrc") . "wincmd w" + call ExpandFilenameAndExecute("split", "~/.vimrc.local") + wincmd l + call ExpandFilenameAndExecute("split", "~/.vimrc.before.local") + wincmd l + call ExpandFilenameAndExecute("split", "~/.vimrc.bundles.local") + + if IsSpf13Fork() + execute bufwinnr(".vimrc") . "wincmd w" + call ExpandFilenameAndExecute("split", "~/.vimrc.fork") + wincmd l + call ExpandFilenameAndExecute("split", "~/.vimrc.before.fork") + wincmd l + call ExpandFilenameAndExecute("split", "~/.vimrc.bundles.fork") + endif + + execute bufwinnr(".vimrc.local") . "wincmd w" + endfunction + + noremap ev :call EditSpf13Config() + noremap sv :source ~/.vimrc " } " Use fork vimrc if available {