]> Sergey Matveev's repositories - dotfiles.git/blobdiff - vim/.vim/plugin/defsplit.vim
Detect already loaded code with simpler <SID> check
[dotfiles.git] / vim / .vim / plugin / defsplit.vim
index f995c8a072f4499927a01f576b113ab0725f45ce..7beb26bc11949cddc49ebac403d6cbde96d988b7 100644 (file)
@@ -32,9 +32,8 @@
 " Also there is :Brsplit command behaving similarly, but it splits other
 " types of brackets: "{}", "[]".
 
-if exists("g:loaded_defsplit") | finish | endif
-let g:loaded_defsplit = 1
 if !exists("g:defsplit_shift") | let g:defsplit_shift = "    " | endif
+if exists('*<SID>Defsplit') | finish | endif
 
 function! s:bracket_find(brs_allowable, line, offset)
     let possible = []
@@ -45,7 +44,7 @@ function! s:bracket_find(brs_allowable, line, offset)
     return min(possible)
 endfunction
 
-function! s:defsplit(brs_allowable, single_line_comma, ...)
+function! s:Defsplit(brs_allowable, single_line_comma, ...)
     if a:0 == 0 | let skip = 0 | else | let skip = str2nr(a:1) | endif
     let shift = g:defsplit_shift
     let line = getline(".")
@@ -95,9 +94,9 @@ function! s:defsplit(brs_allowable, single_line_comma, ...)
     normal "_dd
 endfunction
 
-command! -nargs=? Defsplit call s:defsplit(["("], v:false, <f-args>)
-command! -nargs=? Brsplit call s:defsplit(["(", "[", "{"], v:false, <f-args>)
-command! -nargs=? Defsplits call s:defsplit(["("], v:true, <f-args>)
-command! -nargs=? Brsplits call s:defsplit(["(", "[", "{"], v:true, <f-args>)
+command! -nargs=? Defsplit call s:Defsplit(["("], v:false, <f-args>)
+command! -nargs=? Brsplit call s:Defsplit(["(", "[", "{"], v:false, <f-args>)
+command! -nargs=? Defsplits call s:Defsplit(["("], v:true, <f-args>)
+command! -nargs=? Brsplits call s:Defsplit(["(", "[", "{"], v:true, <f-args>)
 
 command! Undefsplit normal ^v%$J:keepp s/^\(.*\)\([([{]\) \(.*[^,]\),\?\([)\]}]\)\(.*\)$/\1\2\3\4\5<CR>:keepp s/, \?\([)\]}]\+\)$/\1/e<CR>:<CR>