Is there a way in Vim to do the following:
let S = '[''123'', ''456'', ''789'']'
let L = parseStringToList(S)
" L is a list containing the string '123', '456', and '789'
Vi and Vim Stack Exchange is a question and answer site for people using the vi and Vim families of text editors. It only takes a minute to sign up.
Sign up to join this communityYou can do this with eval:
let S = '[''123'', ''456'', ''789'']'
let L = eval(S)
Generally, using eval
is something you should be wary of. Don't run it on untrusted data. But this does solve your problem.
It's possible there's a completely different approach you should be using, but without context, it's hard to say.
let S...
line, you have a list that contains only Strings. So what are you trying to do?let S
, it's a string containing a textual representation of a list, not a list.