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 da850a3..94461e2 100644 --- a/plugin/commentary.vim +++ b/plugin/commentary.vim @@ -102,12 +102,18 @@ function! s:textobject(inner) abort endif endfunction +function s:insert() + let [l, r] = s:surroundings() + return l . r . repeat("\U\", strchars(r)) +endfunction + command! -range -bar -bang Commentary call s:go(,,0) 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 insert() nmap CommentaryUndo :echoerr "Change your CommentaryUndo map to CommentaryCommentary" if !hasmapto('Commentary') || maparg('gc','n') ==# '' @@ -116,6 +122,8 @@ if !hasmapto('Commentary') || maparg('gc','n') ==# '' omap gc Commentary nmap gcc CommentaryLine nmap gcu CommentaryCommentary + imap uCommentaryInsert + imap uCommentaryInsert endif " vim:set et sw=2: