Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Bug fix and improvement for xolox#misc#option#get()

  • Loading branch information...
commit 0b1c06ef1d296590b23bbe4da46faeef6541a8ba 1 parent e228b0e
@xolox authored
Showing with 10 additions and 7 deletions.
  1. +10 −7 option.vim
View
17 option.vim
@@ -1,15 +1,18 @@
" Vim auto-load script
" Author: Peter Odding <peter@peterodding.com>
-" Last Change: June 26, 2011
+" Last Change: June 27, 2011
" URL: http://peterodding.com/code/vim/misc/
-function! xolox#misc#option#get(name, default)
- if exists('g:' . a:name)
- return eval('g:' . a:name)
- elseif exists('b:' . a:name)
+function! xolox#misc#option#get(name, ...)
+ if exists('b:' . a:name)
+ " Buffer local variable.
return eval('b:' . a:name)
- else
- return a:default
+ elseif exists('g:' . a:name)
+ " Global variable.
+ return eval('g:' . a:name)
+ elseif exists('a:1')
+ " Default value.
+ return a:1
endif
endfunction
Please sign in to comment.
Something went wrong with that request. Please try again.