Vim: replacing start and end of a visual char, line or block
- by gattu marrudu
I am trying to find a shortcut to place a custom comment sequence on my code, e.g.:
/*
start of comment
blah
end of comment
/**/
(it is easier to void the comment by just adding a / to the beginning)
I would like to do this in Vim by selecting a visual line, block or char and adding '/' characters at the beginning of the block and '/*/' at the end, plus newlines.
After selecting some lines (Shift-V) I tried this:
'<,'>s/\(.*\)/\/*\r\1\r\/**\//
But it adds the comment chars at EACH newline.
How can I only apply the substitution at the beginning and end of the selected range?
Thanks
gm