aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2019-05-13 00:03:46 +1200
committerTom Ryder <tom@sanctum.geek.nz>2019-05-13 00:03:46 +1200
commit3c7ea4620f20ef87a777597329ca69f8c3a0e708 (patch)
treeb231fa19be7efb6ce28be08891e58caf2d270e62
parentMerge branch 'hotfix/v1.0.2' (diff)
parentBump VERSION (diff)
downloadvim-toggle-flags-3c7ea4620f20ef87a777597329ca69f8c3a0e708.tar.gz
vim-toggle-flags-3c7ea4620f20ef87a777597329ca69f8c3a0e708.zip
Merge branch 'release/v1.1.0'v1.1.0
* release/v1.1.0: Remove unneeded variable scoping Switch to two-spacing
-rw-r--r--README.md4
-rw-r--r--VERSION2
-rw-r--r--doc/toggle_flags.txt8
-rw-r--r--plugin/toggle_flags.vim42
4 files changed, 28 insertions, 28 deletions
diff --git a/README.md b/README.md
index 44aef01..7d51ac2 100644
--- a/README.md
+++ b/README.md
@@ -3,13 +3,13 @@ toggle\_flags.vim
This plugin provides `:ToggleFlag` and `:ToggleFlagLocal` commands to toggle
the values of options like `'formatoptions'` or `'complete'` that have values
-comprised of single-character or comma-separated flags. The author originally
+comprised of single-character or comma-separated flags. The author originally
designed it for toggling flags in `'formatoptions'` quickly.
License
-------
-Copyright (c) [Tom Ryder][1]. Distributed under the same terms as Vim itself.
+Copyright (c) [Tom Ryder][1]. Distributed under the same terms as Vim itself.
See `:help license`.
[1]: https://sanctum.geek.nz/
diff --git a/VERSION b/VERSION
index 6d7de6e..9084fa2 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-1.0.2
+1.1.0
diff --git a/doc/toggle_flags.txt b/doc/toggle_flags.txt
index 81bf04d..74d91f6 100644
--- a/doc/toggle_flags.txt
+++ b/doc/toggle_flags.txt
@@ -5,8 +5,8 @@ DESCRIPTION *toggle_flags*
*:ToggleFlag* *:ToggleFlagLocal*
This plugin provides `:ToggleFlag` and `:ToggleFlagLocal` commands
to toggle the values of options like |'formatoptions'| or |'complete'| that
-have values comprised of single-character or comma-separated flags. The author
-originally designed it for toggling flags in |'formatoptions'| quickly.
+have values comprised of single-character or comma-separated flags. The
+author originally designed it for toggling flags in |'formatoptions'| quickly.
EXAMPLES *toggle_flags-examples*
>
@@ -16,8 +16,8 @@ EXAMPLES *toggle_flags-examples*
<
REQUIREMENTS *toggle_flags-requirements*
-This plugin is only available if 'compatible' is not set. It also requires the
-|+user_commands| Vim feature.
+This plugin is only available if 'compatible' is not set. It also requires
+the |+user_commands| Vim feature.
AUTHOR *toggle_flags-author*
diff --git a/plugin/toggle_flags.vim b/plugin/toggle_flags.vim
index a70e204..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.
+ " 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