sponsor Vim development Vim logo Vim Book Ad

ToggleOptions.vim : Quick toggling of options

 script karma  Rating 0/0, Downloaded by 1009  Comments, bugs, improvements  Vim wiki

created by
Eric Arnold
 
script type
utility
 
description
This allows "toggling" of more complex operations, like switching off "diffthis".  It also reduces the number of key mappings used overall by placing the operations under a key activated command window menu, i.e. if the key map is <leader>o  and <leader> is ",":
     ,o
displays an option list in the command window:
     wrap, Wrapscan, list, binary, modifiable, diff, virtualedit, uhex
so the full command
    ,od
toggles "diff" mode on/off for a window (including foldcolumn=0)
    ,om
toggles "modifiable" and "readonly" together.

You should edit the script to add what want.  E.g.  add your item to the menu call string:

    let l:char = s:Char_menu( "{w}rap, {W}rapscan, {l}ist, {b}inary, {m}odifiable, {d}iff, {v}irtualedit, uhe{x}" )

where {text} is in a different color, then add an elseif clause:

    elseif l:char ==# 'm'
        if &modifiable && !&readonly
            set nomodifiable
            set readonly
        else
            set modifiable
            set noreadonly
        endif
        set readonly?
        set modifiable?
 
install details
Put it in the plugin directory.  Change the <leader>o  key map as desired.
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
ToggleOptions.vim 1 2005-05-09 6.0 Eric Arnold Initial upload
ip used for rating: 142.132.191.50

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github