Thursday, February 6, 2020

Re: join() a list with a newline char for an echo


> I agree that works - but my list is from a ch_read() and has ^@ (NL) at the end of each element
and I just cannot seem to get this work. The join("\n") just puts the ^@ back everywhere.

I don't know what you've got there.  Presumably, you are familiar with the way vim handles NUL
characters (they are stored in memory as newlines, 0x0a, and show as ^@). 

Have you tried chopping off the ends of the elements? Say,

:let my_list = ["alice", "bob", "carol"]
:call map(my_list, {k,v -> v[0:-2]})
:echo my_list
['alic', 'bo', 'caro']

HTH, John Little

--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/2a046725-c7f3-4d9d-b571-0cd9242984ae%40googlegroups.com.

No comments: