0

I know how to use vim's surround plugin to add brackets to a c++ block as follows:

before:

if (condition)
    bla1
    bla2

after:

if (condition)
{    
    bla1
    bla2
}

But what if I want the end result to be:

if (condition) {    
    bla1
    bla2
}

What is the best way to do that?

George B.
  • 565
  • 7
  • 19

1 Answers1

1

I don't know if it's the best way to do that, but you could place your cursor on the if line, and do Shift+J (in normal mode) to join the current line to the next one.

Apitronix
  • 305
  • 2
  • 13
  • 1
    Worst case scenario this is a good way. I am just wondering if it can be done purely by surround's functionality – George B. Apr 09 '20 at 09:22