I want to insert filename and line number into some places in the file. For example this line:
_debug('init');
I want to replace
:s/debug('/debug('(%current_filename_here%:%current_line_number_here%)\ /g
to get this
_debug('(filename.ext:88) init');
I try to use expand('%:t') to get filename and line(".") to get line number, but I don't know how to use it in replace expression.
How can I do this?
You can use \=. For example:
:s@_debug('\zs@\=printf('(%s:%d) ', expand('%:t'), line('.'))@
When the {replacement} starts with
"\="it is evaluated as an expression,
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With