aboutsummaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2019-05-13 00:03:18 +1200
committerTom Ryder <tom@sanctum.geek.nz>2019-05-13 00:03:18 +1200
commitdaa9c0ee5624f0e439195c20aa99a4d27d86524f (patch)
treef9c66b0687ae14b40ad0fcf3c8a63ecdd326456b /plugin
parentSwitch to two-spacing (diff)
downloadvim-toggle-flags-daa9c0ee5624f0e439195c20aa99a4d27d86524f.tar.gz
vim-toggle-flags-daa9c0ee5624f0e439195c20aa99a4d27d86524f.zip
Remove unneeded variable scoping
Diffstat (limited to 'plugin')
-rw-r--r--plugin/toggle_flags.vim36
1 files changed, 18 insertions, 18 deletions
diff --git a/plugin/toggle_flags.vim b/plugin/toggle_flags.vim
index abf21c5..be0cde4 100644
--- a/plugin/toggle_flags.vim
+++ b/plugin/toggle_flags.vim
@@ -5,13 +5,13 @@
" Author: Tom Ryder <tom@sanctum.geek.nz>
" License: Same as Vim itself
"
-if exists('g:loaded_toggle_flags') || &compatible
+if exists('loaded_toggle_flags') || &compatible
finish
endif
if !has('user_commands') || v:version < 600
finish
endif
-let g:loaded_toggle_flags = 1
+let loaded_toggle_flags = 1
" Show an error-highlighted message and beep, but without a real :echoerr
function! s:Error(message)
@@ -25,23 +25,23 @@ endfunction
function! s:Has(option, flag)
" Horrible :execute to get the option's current setting into a variable
- let l:current = ''
- execute 'let l:current = &' . a:option
+ let current = ''
+ execute 'let current = &' . a:option
" If the flag we're toggling is longer than one character, this must by
" necessity be a delimited option. I think all of those in VimL are
" comma-separated. Extend the flag and value so that they'll still match at
" the start and end. Otherwise, use them as-is.
if strlen(a:flag) > 1
- let l:search_flag = ',' . a:flag . ','
- let l:search_value = ',' . l:current . ','
+ let search_flag = ',' . a:flag . ','
+ let search_value = ',' . current . ','
else
- let l:search_flag = a:flag
- let l:search_value = l:current
+ let search_flag = a:flag
+ let search_value = current
endif
" Return whether the flag appears in the value
- return stridx(l:search_value, l:search_flag) > -1
+ return stridx(search_value, search_flag) > -1
endfunction
@@ -61,36 +61,36 @@ function! s:Toggle(option, flag, local)
endif
" Choose which set command to use
- let l:set = a:local
+ let set = a:local
\ ? 'setlocal'
\ : 'set'
" Find whether the flag is set before the change
- let l:before = s:Has(a:option, a:flag)
+ let before = s:Has(a:option, a:flag)
" Assign -= or += as the operation to run based on whether the flag already
" appears in the option value or not
- let l:operation = l:before
+ let operation = before
\ ? '-='
\ : '+='
" Try to set the option; suppress errors, we'll check our work
- silent! execute l:set
+ silent! execute set
\ . ' '
- \ . a:option . l:operation . escape(a:flag, '\ ')
+ \ . a:option . operation . escape(a:flag, '\ ')
" Find whether the flag is set after the change
- let l:after = s:Has(a:option, a:flag)
+ let after = s:Has(a:option, a:flag)
" If we made a difference, report the new value; if we didn't, admit it
- if l:before != l:after
- execute l:set . ' ' . a:option . '?'
+ if before != after
+ execute set . ' ' . a:option . '?'
else
call s:Error('Unable to toggle '.a:option.' flag '.a:flag)
endif
" Return whether we made a change
- return l:before != l:after
+ return before != after
endfunction