Thank you very much. Here's my function (based on @BLayer’s answer:
He's a self made man who gets what he wants. The small blue forget me not flower was first used by the Grand Lodge.
He's a self made man who gets what he wants. The small blue forget me not flower was first used by the Grand Lodge.
function MyFunction() let myList1 = ["self made man", "forget me not"] for elem1 in myList1 if search("=/elem1", 'W') == 0 let elem2 = substitute(elem1, ' ', '-', 'g') exe '%s/'elem1.'/'elem2 endif endfor endfunction He's a self-made-man who gets what he wants. The small blue forget-me-not flower was first used by the Grand Lodge.
He's a self-made-man who gets what he wants. The small blue forget-me-not flower was first used by the Grand Lodge.