Reputation: 1251
using...
2,40s/^/foo
I can add stuff to the start of line(s) in VIM.
using...
2,40s/$/foo
I can add stuff to the end of line(s) in VIM.
My question is... How can I add certain html tags to the end or start of a line in vim?
Example..
2,40s/$/</li>
- This command does not work. I can add <li>
to the end or start, but when I add '/' to it making the closing tag </li>
it doesn't allow it.
I also came across this problem when trying to add 2,40s/^/  to the start of some lines. The '&' character breaks the replace.
Is it possible to be able to add certain tags to vim lines, such as </li>
or & anything?
Upvotes: 0
Views: 259
Reputation: 42218
The other approach would be to use visual block mode with CtrlV, select all the line, then use A, type your tag </foo>
, then ESC.
It will add </foo>
at the end of every line.
Upvotes: 0
Reputation: 1686
You need to escape special characters like / and & with \
Example:
2,40s/^/<pre>
2,40s/$/<\/pre>
2,40s/^/\
If you don't want to escape slashes you can use custom delimiter, in this case #:
2,40s#$#</pre>
Upvotes: 1