0

Say I have the following code

aaa;
bbb;
ccc void () {
    xxx;
    yyy;
}
ddd;
eee;

Now suppose my cursor is at yyy. I'd like to highlight all code between the parenthesis { and } inclusive of the complete line the brackets are on. This means the highlight will look like

before select

enter image description here

after select

enter image description here

va} is not a solution as that produces this

enter image description here

bradgonesurfing
  • 30,949
  • 17
  • 114
  • 217

2 Answers2

2

Effectively it should be a linewise selection. But the corresponding "text-object" forces a charwise one (so there's no difference between va{ and Va{).

However, you can make a selection linewise anytime. So va{V achieves the desired result.

I'm not sure if any mapping is needed at all. But at least ab should not be touched as it normally stands for parentheses ("()-block").

vnoremap aB aBV

Now vaB will select {}-block linewise, while va{ will do "normal" {}-block selection.

Matt
  • 13,674
  • 1
  • 18
  • 27
1
nmap vab va{$o0

Breaking it down

vab

highlights within the brackets inclusive of the brackets. The cursor finishes at the end of the highlight.

$

moves the cursor to the end of the line

o

moves the cursor to the other end of the highlight block

0

moves the cursor to the start of the line

bradgonesurfing
  • 30,949
  • 17
  • 114
  • 217