1

I want to add some text at the beginning/end of selected block(multiple lines) in Vim.

I have the command for single line but not multiple lines:

autocmd BufEnter *.tex,*.html vmap  bb :s/\%V\S.*\S\%>v/\\[ \0 \\]/<CR>

It prefixes and suffixes \[ and \] to selected line.

But I'm looking for a way to multiple lines so that I can prefix/suffix with in multiple lines.

Aron Lee
  • 607
  • 1
  • 5
  • 8
  • Possible duplicate https://stackoverflow.com/questions/253380/how-do-i-insert-text-at-beginning-of-a-multi-line-selection-in-vi-vim – Yonah Dissen Jan 21 '18 at 07:33

1 Answers1

0

Mark the area to be prefix/suffixed as a visual block of lines (V)

and do :s/.*/\\[&\\]/ (or use your short cut bb)

If you do it often, define a short cut (example \q) in your .vimrc

:vmap \q :s/.*/\\[&\\]/<CR>
JJoao
  • 4,891
  • 1
  • 18
  • 20
  • @AronLee, if you have your `bb` command defined, (1) define a visual block of lines = `V` + down-arrows (2) `bb` that should work – JJoao Jan 23 '18 at 20:39