diff --git a/doc/commentary.txt b/doc/commentary.txt index 01f73da..fabaf78 100644 --- a/doc/commentary.txt +++ b/doc/commentary.txt @@ -26,6 +26,10 @@ gc Text object for a comment (operator pending mode gcgc Uncomment the current and adjacent commented lines. gcu + *i_CTRL-/* *i_CTRL-_* +CTRL-/ or CTRL-_ Insert comment delimiters around the cursor in insert + mode. + *:Commentary* :[range]Commentary Comment or uncomment [range] lines diff --git a/plugin/commentary.vim b/plugin/commentary.vim index 7dfc96c..6e47fc2 100644 --- a/plugin/commentary.vim +++ b/plugin/commentary.vim @@ -97,12 +97,18 @@ function! s:textobject(inner) abort endif endfunction +function s:insert() + let [l, r] = s:surroundings() + call feedkeys(l . r . repeat("\", strchars(r)), 'ni') +endfunction + command! -range -bar Commentary call s:go(,) xnoremap Commentary go() nnoremap Commentary go() nnoremap CommentaryLine go() . '_' onoremap Commentary :call textobject(get(v:, 'operator', '') ==# 'c') nnoremap ChangeCommentary c:call textobject(1) +inoremap CommentaryInsert :call insert() nmap CommentaryUndo :echoerr "Change your CommentaryUndo map to CommentaryCommentary" if !hasmapto('Commentary') || maparg('gc','n') ==# '' @@ -114,6 +120,8 @@ if !hasmapto('Commentary') || maparg('gc','n') ==# '' nmap cgc ChangeCommentary endif nmap gcu CommentaryCommentary + imap uCommentaryInsert + imap uCommentaryInsert endif " vim:set et sw=2: