vim - call function inside 'replace' expression
vim
Solution
Once you use a replace-expression, it must be the entire replacement. You can use String concatenation in your expression (and refer to captured elements via `submatch(1)` instead of `\1`), like this:
:%s/regex/\='epoch: ' . localtime()/g
Problem
I understand you can call a function in a vim search/replace operation. For example: ``` %s/regex/\=localtime()/g ``` will replace anything matching 'regex' with the current epoch time. The problem is, I can't add anything else to the 'replace' expression. For example: ``` %s/regex/epoch: \=localtime()/g ``` does not treat 'localtime' as a function anymore. Rather it just prints 'epoch: =localtime()' as a string in the replacement text. The intention is for it to print 'epoch: 1353085984' instead. Is there any way to call a function from within an arbitrary section of a replacement expression?