Allow easy opening of spf13-vim config files

<leader>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

<leader>sv is mapped to a function that reloads the spf13 config
This commit is contained in:
Jim Riordan 2015-06-17 11:41:04 +10:00
parent 03b9801e06
commit 5315ee88d0

42
.vimrc
View File

@ -1150,6 +1150,48 @@
" e.g. Grep current file for <search_term>: Shell grep -Hn <search_term> %
" }
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 <SID>ExpandFilenameAndExecute("tabedit", "~/.vimrc")
call <SID>ExpandFilenameAndExecute("vsplit", "~/.vimrc.before")
call <SID>ExpandFilenameAndExecute("vsplit", "~/.vimrc.bundles")
execute bufwinnr(".vimrc") . "wincmd w"
call <SID>ExpandFilenameAndExecute("split", "~/.vimrc.local")
wincmd l
call <SID>ExpandFilenameAndExecute("split", "~/.vimrc.before.local")
wincmd l
call <SID>ExpandFilenameAndExecute("split", "~/.vimrc.bundles.local")
if <SID>IsSpf13Fork()
execute bufwinnr(".vimrc") . "wincmd w"
call <SID>ExpandFilenameAndExecute("split", "~/.vimrc.fork")
wincmd l
call <SID>ExpandFilenameAndExecute("split", "~/.vimrc.before.fork")
wincmd l
call <SID>ExpandFilenameAndExecute("split", "~/.vimrc.bundles.fork")
endif
execute bufwinnr(".vimrc.local") . "wincmd w"
endfunction
noremap <leader>ev :call <SID>EditSpf13Config()<CR>
noremap <leader>sv :source ~/.vimrc<CR>
" }
" Use fork vimrc if available {