Friday, January 15, 2021

Re: vim9script: dump file content to list of list question !


------ Original Message ------
From: "Ni Va" <nivaemail@gmail.com>
To: "vim_use" <vim_use@googlegroups.com>
Sent: Friday, 15 Jan, 2021 At 13:38
Subject: vim9script: dump file content to list of list question !

Hi,

I got this kind of classical logfile :

2021/01/14 07:42:22.588 Information Foo dbg
2021/01/14 07:42:22.588 Information Bar dbg
2021/01/14 07:42:22.588 Information Foobar dbg
2021/01/14 07:42:22.588 Information Barbar dbg
..
.

and would like to add all lines' informations split by space into dict or array in vim9script.
['2021/01/14', '07:42:22.588', 'Information Foo dbg ']

trying map(getline(1, '$'), ' v:val->split() ') it returns list<list<string>> but impossible to declare var foo: list<list<string>>

How can I fix it ?

Best Wishes 2021
NiVa

Hi

not quite clear on what you want to achieve. If it's lines like the square bracketed example (rather than internal Vim arrays), then you cd use 4 :%s constructs:

:%s/^/['/
:%s/$/']/
:%s/ /','/
:%s/ /','/

which cd of course be canned in a single command. Note not to use a global instead of the two single replacements.

regards - Chris

--
--
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 unsubscribe@googlegroups.com">vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/051f67c9-a061-46a7-9c3b-794b563ea565n%40googlegroups.com.

No comments:

Post a Comment