-1

I have this list :

let myList1 = ["short-term"]

And I want to get this second list with my first :

let myList2 = ["short", "term"]

using

for elem in myList1
     let myList2 = []
     code ???????????/\=add(myList2, submatch(0) 
endfor

Can you help me, please ?

2
  • 1
    How about call extend(myList2, split(elem, "-")), does that do what you want?
    – filbranden
    Mar 21, 2020 at 4:40
  • Yes, it's all right. Thank you. Mar 21, 2020 at 5:24

1 Answer 1

0

Here is my good function :

function! myFunction()

   let myList1 = ["short-term"]
   let myList2 = []
   for elem in myList1  
       call extend(myList2, split(elem, "-"))
   endfor
endfunction 
1
  • please tick your question as answered
    – TornaxO7
    Apr 29, 2021 at 7:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.