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

Re: concatenate with '.' or without

Expand Messages
  • Andy Wokula
    ... Almost ... ... slightly differs from ... The first command echoes the result of {exprN} before evaluating the next. ... func! TestString() echon ! return
    Message 1 of 4 , Apr 1, 2010
    • 0 Attachment
      Am 30.03.2010 19:36, schrieb Tony Mechelynck:
      > On 31/01/10 18:12, Gary Johnson wrote:
      >> On 2010-01-30, Bee wrote:
      >>> On Jan 29, 10:52 am, "Benjamin R. Haskell"<v...@...> wrote:
      >>>> On Fri, 29 Jan 2010, Bee wrote:
      >>>>> On Jan 29, 7:43 am, "Benjamin R. Haskell"<v...@...> wrote:
      >>>>>> ...
      >>>>>> :redir @a
      >>>>>> ...
      >>>>> How to save directly to a filename?
      >>>>> [...]
      >>>>> But this creates a file named savevimrc in $HOME
      >>>>> redir> savevimrc
      >>>>> How to expand savevimrc to the file name?
      >>>> :exe "redir> " . savevimrc
      >>>
      >>> Will this always do the same?
      >>> :exe "redir>" savevimrc
      >>
      >> Yes.
      >>
      >>> From what I have read '.' concatenates without adding spaces,
      >>> whereas without using '.' a space will be added.
      >>
      >> '.' is an expression operator and will concatenate two strings in a
      >> context where an expression is allowed. Not having to use a '.'
      >> between arguments of an exe command is a property of the exe
      >> command, which concatenates all of its arguments with intervening
      >> spaces.
      >>
      >>> Is it just better to get the habit of using '.' ?
      >>
      >> No, not if you're paying attention to the context in which you're
      >> concatenating strings. I prefer not to use the '.' in exe arguments
      >> if I can avoid it because it looks less cluttered.
      >>
      >> Now that I look at them, the examples under ":help :exe" are
      >> confusing. The first two examples include spaces after the executed
      >> command names even though none are needed there.
      >>
      >> Regards,
      >> Gary
      >
      > I agree: both "exe[cute]" and "echo" treat their arguments the same way:
      > any number of expressions are allowed, and their values are concatenated
      > space-separated into one long string before being further processed.
      > Then :echo displays the result while :exe treats it as an ex-command
      > line. IOW you can always use :echo instead of :exe to make sure which
      > ex-command :exe would generate.

      Almost ...

      :echo {expr1} {expr2}

      slightly differs from

      :echo {expr1}.' '.{expr2}

      The first command echoes the result of {exprN} before evaluating the next.

      ------------------
      func! TestString()
      echon '!'
      return 'foo'
      endfunc

      echon TestString() TestString()
      echo ""
      echon TestString()." ".TestString()
      ------------------

      !foo!foo
      !!foo foo

      --
      Andy

      --
      You received this message from the "vim_use" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php
    Your message has been successfully submitted and would be delivered to recipients shortly.