Block comment text-objects

1 Point

Romain Lafourcade Romain Lafourcade

2 years ago

These text-objects allow you to operate directly on block comments.

Example: di?, ya?, etc.

" includes comment markers
xnoremap a? ?<C-r>=split(&commentstring, "%s")[0]<CR><CR>o/<C-r>=split(&commentstring, "%s")[1]<CR><CR>
onoremap a? :<C-u>normal va?<CR>

" excludes comment markers
xnoremap i? ?<C-r>=split(&commentstring, "%s")[0]<CR>?+<CR>o/<C-r>=split(&commentstring, "%s")[1]<CR>/-<CR>
onoremap i? :<C-u>normal vi?<CR>