Edit Page
Source Editor
We recommend that you log in before editing. This will allow other users to leave you a message about your edit, and will let you track edits via your Watchlist. Creating an account is quick and free.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 17: | Line 17: | ||
<pre> |
<pre> |
||
function ToggleFlag(option,flag) |
function ToggleFlag(option,flag) |
||
− | exec ('let lopt = &' . a:option) |
+ | exec ('let lopt = &' . a:option) |
if lopt =~ (".*" . a:flag . ".*") |
if lopt =~ (".*" . a:flag . ".*") |
||
exec ('set ' . a:option . '-=' . a:flag) |
exec ('set ' . a:option . '-=' . a:flag) |
||
Line 28: | Line 28: | ||
Examples of use: |
Examples of use: |
||
<pre> |
<pre> |
||
− | map |
+ | map <silent> <F8> :call ToggleFlag("guioptions","m")<CR> |
− | map |
+ | map <silent> <F9> :call ToggleFlag("guioptions","T")<CR> |
</pre> |
</pre> |
||
Line 38: | Line 38: | ||
" my function to cycle a numeric option |
" my function to cycle a numeric option |
||
function CycleNum(option,min,inc,max) |
function CycleNum(option,min,inc,max) |
||
− | exec ('let tz_value = (((&'.a:option.'-'.a:min.')+'.a:inc.')%(('.a:max.'-'.a:min.')+'.a:inc.'))+'.a:min) |
+ | exec ('let tz_value = (((&'.a:option.'-'.a:min.')+'.a:inc.')%(('.a:max.'-'.a:min.')+'.a:inc.'))+'.a:min) |
− | if (tz_value |
+ | if (tz_value < a:min) " in case inc<0 |
let tz_value = tz_value+a:max |
let tz_value = tz_value+a:max |
||
endif |
endif |
||
Line 47: | Line 47: | ||
" my function to toggle an option flag |
" my function to toggle an option flag |
||
function ToggleFlag(option,flag) |
function ToggleFlag(option,flag) |
||
− | exec ('let tf_o = &'.a:option) |
+ | exec ('let tf_o = &'.a:option) |
exec ('setlocal '.a:option.'-='.a:flag) |
exec ('setlocal '.a:option.'-='.a:flag) |
||
− | exec ('let tf_t = &'.a:option) |
+ | exec ('let tf_t = &'.a:option) |
if (tf_o == tf_t) |
if (tf_o == tf_t) |
||
exec ('setlocal '.a:option.'+='.a:flag) |
exec ('setlocal '.a:option.'+='.a:flag) |
||
Line 56: | Line 56: | ||
" Toggle folding column |
" Toggle folding column |
||
− | noremap |
+ | noremap <silent> <F7> :call CycleNum("foldcolumn",0,2,6)<BAR>set foldcolumn?<CR> |
− | imap |
+ | imap <F7> <C-O><F7> |
" Toggle window appearance |
" Toggle window appearance |
||
− | noremap |
+ | noremap <silent> <F8> :call ToggleFlag("guioptions","m")<BAR>set guioptions?<CR> |
− | imap |
+ | imap <F8> <C-O><F8> |
− | noremap |
+ | noremap <silent> <F9> :call ToggleFlag("guioptions","T")<BAR>set guioptions?<CR> |
− | imap |
+ | imap <F9> <C-O><F9> |
" Cycle tabstop |
" Cycle tabstop |
||
− | noremap |
+ | noremap <silent> <M-t>s :call CycleNum("tabstop",4,4,8)<BAR>set tabstop?<CR> |
" Cycle shiftwidth |
" Cycle shiftwidth |
||
− | noremap |
+ | noremap <silent> <M-t>w :call CycleNum("shiftwidth",4,4,8)<BAR>set shiftwidth?<CR> |
</pre> |
</pre> |
||