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 = &amp;' . 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 <silent> <F8> :call ToggleFlag("guioptions","m")<CR>
+
map &lt;silent&gt; &lt;F8&gt; :call ToggleFlag("guioptions","m")&lt;CR&gt;
map <silent> <F9> :call ToggleFlag("guioptions","T")<CR>
+
map &lt;silent&gt; &lt;F9&gt; :call ToggleFlag("guioptions","T")&lt;CR&gt;
 
</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 = (((&amp;'.a:option.'-'.a:min.')+'.a:inc.')%(('.a:max.'-'.a:min.')+'.a:inc.'))+'.a:min)
if (tz_value < a:min) " in case inc<0
+
if (tz_value &lt; a:min) " in case inc&lt;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 = &amp;'.a:option)
 
exec ('setlocal '.a:option.'-='.a:flag)
 
exec ('setlocal '.a:option.'-='.a:flag)
exec ('let tf_t = &'.a:option)
+
exec ('let tf_t = &amp;'.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 <silent> <F7> :call CycleNum("foldcolumn",0,2,6)<BAR>set foldcolumn?<CR>
+
noremap &lt;silent&gt; &lt;F7&gt; :call CycleNum("foldcolumn",0,2,6)&lt;BAR&gt;set foldcolumn?&lt;CR&gt;
imap <F7> <C-O><F7>
+
imap &lt;F7&gt; &lt;C-O&gt;&lt;F7&gt;
   
 
" Toggle window appearance
 
" Toggle window appearance
noremap <silent> <F8> :call ToggleFlag("guioptions","m")<BAR>set guioptions?<CR>
+
noremap &lt;silent&gt; &lt;F8&gt; :call ToggleFlag("guioptions","m")&lt;BAR&gt;set guioptions?&lt;CR&gt;
imap <F8> <C-O><F8>
+
imap &lt;F8&gt; &lt;C-O&gt;&lt;F8&gt;
noremap <silent> <F9> :call ToggleFlag("guioptions","T")<BAR>set guioptions?<CR>
+
noremap &lt;silent&gt; &lt;F9&gt; :call ToggleFlag("guioptions","T")&lt;BAR&gt;set guioptions?&lt;CR&gt;
imap <F9> <C-O><F9>
+
imap &lt;F9&gt; &lt;C-O&gt;&lt;F9&gt;
   
 
" Cycle tabstop
 
" Cycle tabstop
noremap <silent> <M-t>s :call CycleNum("tabstop",4,4,8)<BAR>set tabstop?<CR>
+
noremap &lt;silent&gt; &lt;M-t&gt;s :call CycleNum("tabstop",4,4,8)&lt;BAR&gt;set tabstop?&lt;CR&gt;
 
" Cycle shiftwidth
 
" Cycle shiftwidth
noremap <silent> <M-t>w :call CycleNum("shiftwidth",4,4,8)<BAR>set shiftwidth?<CR>
+
noremap &lt;silent&gt; &lt;M-t&gt;w :call CycleNum("shiftwidth",4,4,8)&lt;BAR&gt;set shiftwidth?&lt;CR&gt;
 
</pre>
 
</pre>
   

Please note that all contributions to the Vim Tips Wiki are considered to be released under the CC-BY-SA

Cancel Editing help (opens in new window)