From e12de1a34d50cd0076b89cd273e8f5a71515ef8f Mon Sep 17 00:00:00 2001 From: "Devin J. Pohly" Date: Fri, 29 May 2026 19:04:44 -0500 Subject: [PATCH] Use () around mappings is merely a special keycode, so "Commentary" is a prefix of e.g. "CommentaryLine", which means you have to wait for 'timeoutlen' before the former mapping takes place to make sure you're not actually going to enter the latter. (Type "gcLine" from Normal mode, watch the 'showcmd' output and see what gets called!) It's common practice to use parentheses to prevent one mapping from prefixing another, so that's the fix suggested here. (Another option would be a terminator, as suggested in ":help using-".) May be related to the issue seen in #105, given that it was affected by changes to 'timeoutlen'. --- plugin/commentary.vim | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/plugin/commentary.vim b/plugin/commentary.vim index 079bce1..8671f6a 100644 --- a/plugin/commentary.vim +++ b/plugin/commentary.vim @@ -103,20 +103,20 @@ function! s:textobject(inner) abort 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) +xnoremap (Commentary) go() +nnoremap (Commentary) go() +nnoremap (CommentaryLine) go() . '_' +onoremap (Commentary) :call textobject(get(v:, 'operator', '') ==# 'c') +nnoremap (ChangeCommentary) c:call textobject(1) -if !hasmapto('Commentary') || maparg('gc','n') ==# '' - xmap gc Commentary - nmap gc Commentary - omap gc Commentary - nmap gcc CommentaryLine - nmap gcu CommentaryCommentary +if !hasmapto('(Commentary)') || maparg('gc','n') ==# '' + xmap gc (Commentary) + nmap gc (Commentary) + omap gc (Commentary) + nmap gcc (CommentaryLine) + nmap gcu (Commentary)(Commentary) endif -nmap CommentaryUndo :echoerr "Change your CommentaryUndo map to CommentaryCommentary" +nmap (CommentaryUndo) :echoerr "Change your (CommentaryUndo) map to (Commentary)(Commentary)" " vim:set et sw=2: