runtime(comment): add gC mapping to (un)comment rest of line

fixes: #15727
closes: #15737

Signed-off-by: Konfekt <Konfekt@users.noreply.github.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Konfekt
2024-09-29 10:46:41 +02:00
committed by Christian Brabandt
parent 8feed3a525
commit 9142136161
3 changed files with 31 additions and 10 deletions

View File

@ -1,4 +1,4 @@
*comment.txt* For Vim version 9.1. Last change: 2024 Jun 04
*comment.txt* For Vim version 9.1. Last change: 2024 Sep 29
VIM REFERENCE MANUAL
@ -12,17 +12,26 @@ See |comment-install| on how to activate this package.
The comment.vim package, allows to toggle comments for a single line, a range
of lines or a selected text object. It defines the following mappings:
*gcc*
gcc to comment/uncomment current line
*o_gc*
gc{motion} to toggle comments for the selected motion
*gcip*
gcip to comment/uncomment current paragraph
*gcG*
gcG to comment/uncomment from current line till the end of a buffer
*v_gc*
{Visual}gc to comment/uncomment the highlighted lines.
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:
*gcc*
gcc to comment/uncomment current line
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: >
nnoremap <silent> <expr> gC comment.Toggle() .. '$'
<
Note: using `gC` may not always result in valid comment markers depending on
the language used.
This plugin uses the buffer-local 'commentstring' option value to add or remove
comment markers to the selected lines. Whether it will comment or un-comment
depends on the first line of the range of lines to act upon. When it matches

View File

@ -1,8 +1,6 @@
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*
gcG comment.txt /*gcG*
gcc comment.txt /*gcc*
gcip comment.txt /*gcip*
o_gc comment.txt /*o_gc*
v_gc comment.txt /*v_gc*