Tip 1033 Printable Monobook Previous Next
created October 31, 2005 · complexity intermediate · author Bertram Scharpf · version 6.0
When editing config files, you may need to frequently convert between yes and no settings.
With the following in your vimrc, you can press gy to toggle between the words shown in the script.
function s:ToggleYesNo() let w=expand("<cword>") if w=="yes" | let w="no" elseif w=="no" | let w="yes" elseif w=="on" | let w="off" elseif w=="off" | let w="on" elseif w=="manual" | let w="auto" elseif w=="auto" | let w="manual" else | let w="" endif if w!="" exec "normal! \"_ciw\<C-R>=w\<cr>\<Esc>b" endif endfunc nnoremap gy :call <SID>ToggleYesNo()<cr>
This could be supplemented with:
else let n=strpart(w,0,2) if n=="no" let w=strpart(w,2) else let w="no".w endif endif