diff --git a/runtime/pack/dist/opt/comment/doc/comment.txt b/runtime/pack/dist/opt/comment/doc/comment.txt index be8cb84e65..2286f07851 100644 --- a/runtime/pack/dist/opt/comment/doc/comment.txt +++ b/runtime/pack/dist/opt/comment/doc/comment.txt @@ -1,4 +1,4 @@ -*comment.txt* For Vim version 9.1. Last change: 2025 Mar 21 +*comment.txt* For Vim version 9.1. Last change: 2025 Jun 22 VIM REFERENCE MANUAL @@ -19,16 +19,17 @@ gc{motion} to toggle comments for the selected motion Since gc operates on a motion, it can be used with any motion, for example _ to comment the current line, or ip to comment the current paragraph. -A default mapping `gcc` to `gc_` is defined: +Default mappings are defined for `gc_` and `gc$`: *gcc* -gcc to comment/uncomment current line +gcc to comment/uncomment current line (same as `gc_`) -To comment the rest of the line by `gC` whenever the filetype plugin -supports it (that is, whenever the comment marker precedes the code) and fall -back to `gcc` otherwise, add the following mapping to your vimrc: > + *gC* +gC to comment/uncomment to end of current line (same as `gc$`) + +Commenting to the end of a line using `gC` works whenever the filetype plugin +supports it (that is, whenever the comment marker precedes the code) and falls +back to `gcc` otherwise. - nnoremap gC comment#Toggle() .. '$' -< Note: using `gC` may not always result in valid comment markers depending on the language used. @@ -85,5 +86,46 @@ Options: Use g:comment_first_col to change it globally or b:comment_first_col to target specific filetype(s). +*g:comment_mappings* + Set to false to disable the default keyboard mappings, e.g. in your vimrc +> + let g:comment_mappings = v:false +< + This option must be set before the package is activated using |packadd|. + +============================================================================== +Mappings: + +The following || mappings are included, which you can use to customise the +keyboard mappings. + +*(comment-toggle)* + Normal and visual modes, mapped to gc by default + +*(comment-toggle-line)* + Normal mode only, mapped to gcc by default + +*(comment-toggle-end)* + Normal mode only, mapped to gC by default + +*(comment-text-object-inner)* + Operator pending and visual modes, mapped to ic by default + +*(comment-text-object-outer)* + Operator pending and visual modes, mapped to ac by default + +The default keyboard mappings are shown below, you can copy these if you wish +to customise them in your vimrc: +> + nmap gc (comment-toggle) + xmap gc (comment-toggle) + nmap gcc (comment-toggle-line) + nmap gC (comment-toggle-end) + + omap ic (comment-text-object-inner) + omap ac (comment-text-object-outer) + xmap ic (comment-text-object-inner) + xmap ac (comment-text-object-outer) +< ============================================================================== vim:tw=78:ts=8:fo=tcq2:ft=help: diff --git a/runtime/pack/dist/opt/comment/doc/tags b/runtime/pack/dist/opt/comment/doc/tags index 62c4afd6d9..6096d114ca 100644 --- a/runtime/pack/dist/opt/comment/doc/tags +++ b/runtime/pack/dist/opt/comment/doc/tags @@ -1,7 +1,14 @@ +(comment-text-object-inner) comment.txt /*(comment-text-object-inner)* +(comment-text-object-outer) comment.txt /*(comment-text-object-outer)* +(comment-toggle) comment.txt /*(comment-toggle)* +(comment-toggle-end) comment.txt /*(comment-toggle-end)* +(comment-toggle-line) comment.txt /*(comment-toggle-line)* ac comment.txt /*ac* b:comment_first_col comment.txt /*b:comment_first_col* comment.txt comment.txt /*comment.txt* g:comment_first_col comment.txt /*g:comment_first_col* +g:comment_mappings comment.txt /*g:comment_mappings* +gC comment.txt /*gC* gcc comment.txt /*gcc* ic comment.txt /*ic* o_gc comment.txt /*o_gc* diff --git a/runtime/pack/dist/opt/comment/plugin/comment.vim b/runtime/pack/dist/opt/comment/plugin/comment.vim index 67b431de6e..62817ddfe0 100644 --- a/runtime/pack/dist/opt/comment/plugin/comment.vim +++ b/runtime/pack/dist/opt/comment/plugin/comment.vim @@ -2,14 +2,28 @@ vim9script # Maintainer: Maxim Kim # Last Update: 2025 Mar 21 +# 2025 Jun 22 by Vim Project: add mappings #17563 import autoload 'comment.vim' -nnoremap gc comment.Toggle() -xnoremap gc comment.Toggle() -nnoremap gcc comment.Toggle() .. '_' +nnoremap (comment-toggle) comment.Toggle() +xnoremap (comment-toggle) comment.Toggle() +nnoremap (comment-toggle-line) comment.Toggle() .. '_' +nnoremap (comment-toggle-end) comment.Toggle() .. '$' -onoremap ic comment.ObjComment(v:true) -onoremap ac comment.ObjComment(v:false) -xnoremap ic comment.ObjComment(v:true) -xnoremap ac comment.ObjComment(v:false) +onoremap (comment-text-object-inner) comment.ObjComment(v:true) +onoremap (comment-text-object-outer) comment.ObjComment(v:false) +xnoremap (comment-text-object-inner) comment.ObjComment(v:true) +xnoremap (comment-text-object-outer) comment.ObjComment(v:false) + +if get(g:, 'comment_mappings', true) + nmap gc (comment-toggle) + xmap gc (comment-toggle) + nmap gcc (comment-toggle-line) + nmap gC (comment-toggle-end) + + omap ic (comment-text-object-inner) + omap ac (comment-text-object-outer) + xmap ic (comment-text-object-inner) + xmap ac (comment-text-object-outer) +endif