I wrote some vim plugin, that correctly works with vim8, but when I try run it with neovim I get error about invalid expression in string:

let var = str_first .. str_second

When I change .. to . all works fine, so I want to ask: string concatenation by .. is right? Why vim support both operators . and .., but neovim support only .?

  • :help expr-..
    – Matt
    Dec 25 '20 at 13:34
  • 2
    BTW. Neovim also supports both operators (at least, current beta version).
    – Matt
    Dec 25 '20 at 13:36

The .. string concatenation operator was added to Vim fairly recently, as of version 8.1.1114 from April 2019.

The documentation at :help expr-.. explains the rationale for adding it:

For String concatenation .. is preferred, since . is ambiguous, it is also used for Dict member access and floating point numbers.

This commit has been ported to NeoVim in May 2019 and it's present in NeoVim v0.4.4, the latest release of NeoVim as of this writing.

If you care about compatibility with older versions, you might want to stick with using . as a string concatenation operator. It's still around and it's not really going anywhere anytime soon.

  • 1
    Or printf, which I find easier
    – D. Ben Knoble
    Dec 25 '20 at 22:19
  • 1
    I'm still always using .: it works with every version of Vim I may still have to use. Dec 26 '20 at 11:32

This site is temporarily in read only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .