Loading ...
Sorry, an error occurred while loading the content.

check if guioption is set

Expand Messages
  • Kim Schulz
    hi is there a way to check if a guioption is set. normally I would use somthing like: if guioptions == m :set guioptions-=m :else :set
    Message 1 of 3 , Jul 29, 2006
    View Source
    • 0 Attachment
      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.

      --
      Kim Schulz | Private : http://www.schulz.dk
      Kim@... | Business: http://www.devteam.dk
      +45 5190 4262 | Sparetime: http://www.fundanemt.com
    • A.J.Mechelynck
      ... - 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
      Message 2 of 3 , Jul 29, 2006
      View Source
      • 0 Attachment
        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.
      • Yakov Lerner
        ... if & guioptions =~# m | set guioptions-=m else | guioptions+=m | endif Operator =~# matches case-sensitive. Operator =~? matches case-insensitive. ...
        Message 3 of 3 , Jul 29, 2006
        View Source
        • 0 Attachment
          On 7/29/06, Kim Schulz <kim@...> 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.

          if & guioptions =~# 'm' | set guioptions-=m
          else | guioptions+=m | endif

          Operator =~# matches case-sensitive.
          Operator =~? matches case-insensitive.
          :help =~#
          :help =~?

          Yakov
        Your message has been successfully submitted and would be delivered to recipients shortly.