Add parentheses to the current line

2 Points

Antoine Snyers Antoine Snyers

4 months 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>