suppose I have a variable named
a_variable
is there a surround or some combination of keystrokes which will do
print(a_variable)
or
print("a_variable: ", a_variable)
when my cursor in on the line where a_variable
is defined ?
I could not find any relevant material on the web .
Any help is appreciated.
This answers is written with Vim in mind. Some, all, or none of it may apply to your specific Vim emulator so YMMV.
You can position your cursor on a_variable
and do:
ysiwfprint(<CR>
to obtain:
print(a_variable)
It is currently impossible to achieve with surround only.
You can position your cursor on a_variable
and do:
ciwprint(<C-r>")<Esc>
The scond case is a variant of the first case where you insert the variable name two times instead of one:
ciwprint("<C-r>": ", <C-r>")<Esc>
Turn it into a mapping if you need to do it often.
See :help c
, :help iw
, :help i_ctrl-r
, :help ""
.