Is it possible to pass a variable to a function in vimscript, and then use that value in a search and replace regex?
function! AddTW5Links(tiddlerSetName) %s/\(*\+\)\(\[\[\(.*\)\)\]\]/\1[[\3|\3 - $tiddlerSetName]]/g endfunction
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 community
You have the choice between using
:exe, or using
:exe 's/\(*\+\)\(\[\[\(.*\)\)\]\]/\1[[\3|\3 - '.a:tiddlerSetName.']]/g'
(beware of double-quote, you'll have to double all your backslashes with them)
:s/\(*\+\)\(\[\[\(.*\)\)\]\]/=submatch(1).'[['.submatch(3).'|'.submatch(3).' - '.a:tiddlerSetName.']]'/g