Add parentheses to the current line

1 Point

Antoine Snyers Antoine Snyers

1 week ago

Map commands for wrapping regions of the current line in parentheses

example usage on this line:

the quick brown fox


hit (( with the cursor anywhere on this line

(the quick brown fox)


hit )) with the cursor on b

the quick (brown fox)


hit () with the cursor on k

(the quick) brown fox


" wrap the current line in (), e.g:
nnoremap (( mMI(<esc>A)<esc>`M

" wrap the rest of the line in ()
nnoremap )) mMi(<esc>A)<esc>`M

" wrap the line so far in ()
nnoremap () mMI(<esc>`Mla)<esc>