J
J
JZorkiy2019-05-12 15:09:33
vim
JZorkiy, 2019-05-12 15:09:33

vim. Selected number of lines. How to replace at the beginning and end of each selected line?

Important!
You need a command like:
:s/.../.../
, which can be put on a keyboard shortcut. The working option, if you enter the command manually is:
:s/^\s*/&<-- / | '<,'>s/$/ -->/
, but if this command is mapped into vimrc, then it only works up to the logical "and" ( | ).
Can anyone suggest a solution?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
SilentFl, 2019-05-16
@JZorkiy

:'<,'>s/\(^\s*\)\(.*\)$/\1<-- \2 -->/g
but I will join arsenty - take nerd-tree-commenter
if there is no support for the desired extension/language - then it is very easy to add it yourself ( example )

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question