Kim Schulz wrote:
hi
is there a way to check if a guioption is set. normally I would use somthing like:
if guioptions == m :set guioptions-=m<cr>:else<cr>:set
guioptions+=m<cr>:endif<cr>
but since guioptions is a sequence of options and not just a single
letter, this wont work. So how do I check if it is set? I was looking for somthing like the ~= in perl but didn't seem to find such a thing.

- The operators a =~ b (string a matches regexp b) and a !~ b (string a doesn't match regexp b) seem to be what you want;
- To access an option as if it were a variable, prefix its name with &

To toggle flag m if guioptions:

        if &guioptions =~ "m"
                set guioptions-=m
        else
                set guioptions+=m
        endif

In a mapping:

:map <F5> :if &go =~ "m" <Bar> set go-=m <Bar> else <Bar> set go+=m <Bar> endif<CR>

(all on one line)


See
        :help expr4
        :help expr-option
        :help :bar
        :help map_bar


HTH,
Tony.

Reply via email to