• VIM question - string concatenation

    From Kenny McCormack@21:1/5 to All on Wed Nov 29 12:13:09 2023
    XPost: comp.unix.shell

    Note: Normally, I would post this (only) to comp.editors, but (at least on
    my server) comp.editors is destroyed by the Google spam and is unusable.
    So, if you respond (post) to comp.editors (only), I won't see it. I am reading/posting only via the "shell" group.

    In VIM, if you do: :echo 'this is a test' strftime('%c')
    you get: this is a test Wed ...

    I.e., it concats the strings together, but with a space between. Removing
    the space from the command line: :echo 'this is a test'strftime('%c')
    does not help. It still concats with a space.

    Is there a way to concat without the space?

    Note: I would normally try to look this up in the VIM help, but it is hard
    to search for stuff related to the basic syntax of the language. What
    would you search on?

    --
    The key difference between faith and science is that in science, evidence that doesn't fit the theory tends to weaken the theory (that is, make it less likely to
    be believed), whereas in faith, contrary evidence just makes faith stronger (on the assumption that Satan is testing you - trying to make you abandon your faith).

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kenny McCormack@21:1/5 to 433-929-6894@kylheku.com on Wed Nov 29 18:12:06 2023
    XPost: comp.unix.shell

    In article <20231129082426.511@kylheku.com>,
    Kaz Kylheku <433-929-6894@kylheku.com> wrote:
    On 2023-11-29, Tom Furie <tom@furie.org.uk> wrote:
    gazelle@shell.xmission.com (Kenny McCormack) writes:

    In VIM, if you do: :echo 'this is a test' strftime('%c')
    you get: this is a test Wed ...

    Is there a way to concat without the space?

    According to ':h echo' in vim, each expression is printed with a space
    between, so it doesn't look like it.

    Expressions in Vim can be catenated with the dot operator.

    For instance :echo "a" . "b" prints ab for me.

    Thank you!

    Yes, that jogs my memory. I had used . previously, but it has been a long time.

    Usenet at its finest. The system works!


    --
    Joni Ernst (2014): Obama should be impeached because 2 people have died of Ebola.
    Joni Ernst (2020): Trump is doing great things, because only 65,000 times as many people have died of COVID-19.

    Josef Stalin (1947): When one person dies, it is a tragedy; when a million die, it is merely statistics.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Stan Brown@21:1/5 to Kenny McCormack on Wed Nov 29 19:02:49 2023
    XPost: comp.unix.shell

    On Wed, 29 Nov 2023 12:13:09 -0000 (UTC), Kenny McCormack wrote:

    Note: Normally, I would post this (only) to comp.editors, but (at least on
    my server) comp.editors is destroyed by the Google spam and is unusable.
    So, if you respond (post) to comp.editors (only), I won't see it. I am reading/posting only via the "shell" group.

    In VIM, if you do: :echo 'this is a test' strftime('%c')
    you get: this is a test Wed ...

    I.e., it concats the strings together, but with a space between.

    I don't think it does. You have two expressions there, a string
    constant and a string function. :echo shows however many expressions
    you have on the command line, separated by a space.

    Is there a way to concat without the space?

    Use a dot ("period" in the US):

    :echo 'this is a test' . strftime('%c')

    That is the concatenation operator. If you use my :echo command, it
    is now one expression, and therefore no space is inserted as it was
    when you had two expressions.

    Note: I would normally try to look this up in the VIM help, but it is hard
    to search for stuff related to the basic syntax of the language. What
    would you search on?

    :h expression-syntax

    N.B. I'm still running Vim 7.4, so it's conceivable that "." works
    differently in Vim 9, but I think it's pretty unlikely. Anyway, it's
    easy to check.

    --
    Stan Brown, Tehachapi, California, USA https://BrownMath.com/
    Shikata ga nai...

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)