• Re: VIM question - string concatenation

    From marrgol@21:1/5 to All on Wed Nov 29 13:40:48 2023
    XPost: comp.editors

    On 2023-11-29 at 13:13 Kenny McCormack wrote:
    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?

    :echon 'this is a test'strftime('%c')

    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?

    I did :h echo and found echon right below.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From marrgol@21:1/5 to All on Wed Nov 29 13:41:41 2023
    On 2023-11-29 at 13:13 Kenny McCormack wrote:
    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?

    :echon 'this is a test'strftime('%c')

    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?

    I did :h echo and found echon right below.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Tom Furie@21:1/5 to Kenny McCormack on Wed Nov 29 12:31:54 2023
    XPost: comp.editors

    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?

    You could try ':echon', though...

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Tom Furie@21:1/5 to Kenny McCormack on Wed Nov 29 12:29:02 2023
    XPost: comp.editors

    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kenny McCormack@21:1/5 to tom@furie.org.uk on Wed Nov 29 14:38:21 2023
    XPost: comp.editors

    In article <uk7aq9$i4p$1@freeq.furie.org.uk>,
    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.

    According to other posters downthread, 'echon' solves the problem, for
    echo. But (and this is critical), 'echo' is not the point. I was only
    using echo for demonstration purposes.

    I actually came across this problem in another context, that did not
    involve echo. I found that I always got the extra space in there.

    So, there needs to be a way to do string concatenation that does not insert
    the space.

    --
    The single most important statistic in the US today - the one that explains all the
    others - is this: 63 million people thought it was a good idea to vote for this clown
    (and will probably do so again). Everything else is secondary to that. Everything else
    could be fixed if we can revert this one statistic. Nothing can be fixed until we do.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Tom Furie@21:1/5 to Kenny McCormack on Wed Nov 29 15:25:10 2023
    XPost: comp.editors

    gazelle@shell.xmission.com (Kenny McCormack) writes:

    According to other posters downthread, 'echon' solves the problem, for
    echo. But (and this is critical), 'echo' is not the point. I was only
    using echo for demonstration purposes.

    I actually came across this problem in another context, that did not
    involve echo. I found that I always got the extra space in there.

    So, there needs to be a way to do string concatenation that does not insert the space.

    The only example you gave was with echo, so you were given an
    echo-oriented solution. Perhaps if you provide the context in which
    you're *actually* encountering the problem that can be addressed.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kaz Kylheku@21:1/5 to Tom Furie on Wed Nov 29 16:26:37 2023
    XPost: comp.editors

    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.

    Likewise, :echo "a" . strftime('%s') prints aWed...

    --
    TXR Programming Language: http://nongnu.org/txr
    Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
    Mastodon: @Kazinator@mstdn.ca
    NOTE: If you use Google Groups, I don't see you, unless you're whitelisted.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Kaz Kylheku@21:1/5 to Kenny McCormack on Wed Nov 29 19:16:40 2023
    XPost: comp.editors

    On 2023-11-29, Kenny McCormack <gazelle@shell.xmission.com> wrote:
    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.

    I also used it; and by golly there are multiple examples in my now
    ancient .vimrc.

    Here is one. Well, two:

    :nmap K "_y:execute count ? ( ":!man " . count . " " . expand("<cword>") ) : ( ":grep \\<" . expand("<cword>") . "\\>")<CR>
    :vmap K "zy:execute ":grep " . getreg("z")<CR>

    The built-in K command does man page lookup normally for the word under
    the cursor. If you give it a numeric prefix, it will look in that
    section of the man system; 2K will do a "man 2 <word>".

    I wanted K to do a :grep through the code I'm working on,
    but retain the prefixed K functionality for man page lookups.

    --
    TXR Programming Language: http://nongnu.org/txr
    Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
    Mastodon: @Kazinator@mstdn.ca
    NOTE: If you use Google Groups, I don't see you, unless you're whitelisted.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Onorio Catenacci@21:1/5 to Kenny McCormack on Wed Nov 29 15:23:53 2023
    XPost: comp.editors

    On 11/29/23 7:13 AM, 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. 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?


    May not be totally appropriate to mention this here (if not apologies in advance) but this is another resource for Vi/Vim questions: https://vi.stackexchange.com

    Since this is the only thread I've seen recently in comp.editors that
    isn't spam (or trash) I wanted to try to contribute something worthwhile
    to the conversation.

    --
    oc

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