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

Re: :let and :set with whitespaces

Expand Messages
  • Stahlman Family
    ... Aarto, You can use arbitrary expressions on the rhs if you use the let-& syntax: e.g., let &tabstop = 2 + 2 ... Brett Stahlman ... -- You received this
    Message 1 of 3 , Dec 1, 2009
    • 0 Attachment
      Aarto Matti wrote:
      > Hi,
      >
      > I can freely use whitespaces with let command, both "let my_var = 1" and
      > "let my_var=1" are equal correct, but something like "set tabstop = 4" is
      > impossible. Any reason why there are such restrictions in VimL?

      Aarto,
      You can use arbitrary expressions on the rhs if you use the let-&
      syntax: e.g.,

      let &tabstop = 2 + 2

      :help let-&

      Brett Stahlman

      >

      --
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
    • Tony Mechelynck
      ... After :let , whitespace can only happen as part of a single- or double-quoted string. After :set , quotes are not used, multiple option=value operands
      Message 2 of 3 , Dec 1, 2009
      • 0 Attachment
        On 01/12/09 12:33, Aarto Matti wrote:
        > Hi,
        >
        > I can freely use whitespaces with let command, both "let my_var = 1" and
        > "let my_var=1" are equal correct, but something like "set tabstop = 4"
        > is impossible. Any reason why there are such restrictions in VimL?

        After ":let", whitespace can only happen as part of a single- or
        double-quoted string. After ":set", quotes are not used, multiple
        option=value operands can be used, and whitespace after the equal sign
        terminates the value unless it is backslash-escaped:

        :set option = value

        is illegal unless 'option' exists as a String option AND 'value' exists
        as an option-name, in which case it sets 'option' to the empty string,
        and sets 'value' to TRUE if Boolean or displays its present value otherwise

        :set option = "value"

        (where 'option' is a String option) sets 'option' to the empty string,
        and is followed by a Vim comment starting with a double quote.

        :set list listchars=tab:\ \ ,eol:ś

        sets Vim to display the end-of-line as ś and tabs normally (as between
        one and 'tabstop' spaces), not as ^I (like with the tab: suboption
        omitted) and not as something visible.

        :set title=\ \ \ \ \ Hello

        sets the 'title' option to the word "Hello" preceded by five spaces.

        The "tradition" is to use spaces around the = of ":let", the operators
        (such as + - * / == ==? != =~ !~ etc.) in expressions, but not after
        ":set" except of course if backslash-escaped as part of a String value.

        I assume that these restrictions are inherited from Vi.


        Best regards,
        Tony.
        --
        "The first rule of magic is simple. Don't waste your time waving your
        hands and hoping when a rock or a club will do."
        -- McCloctnik the Lucid

        --
        You received this message from the "vim_use" maillist.
        For more information, visit http://www.vim.org/maillist.php
      Your message has been successfully submitted and would be delivered to recipients shortly.