patch 9.1.1229: the comment plugin can be improved

Problem:  the comment plugin can be improved
Solution: add comment text objects "ic" and "ac"
          (Maxim Kim)

closes: #16938

Signed-off-by: Maxim Kim <habamax@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Maxim Kim
2025-03-21 18:02:56 +01:00
committed by Christian Brabandt
parent 51a06ecee0
commit 9712a2534f
6 changed files with 451 additions and 8 deletions

View File

@ -1,4 +1,4 @@
*comment.txt* For Vim version 9.1. Last change: 2024 Oct 01
*comment.txt* For Vim version 9.1. Last change: 2025 Mar 21
VIM REFERENCE MANUAL
@ -32,11 +32,20 @@ back to `gcc` otherwise, add the following mapping to your vimrc: >
Note: using `gC` may not always result in valid comment markers depending on
the language used.
Additionally, the plugin defines a comment text-object which requires syntax
highlighting to be enabled.
*v_ac* *ac*
ac "a comment", select current or next comment.
Leading and trailing white space is included.
Trailing newlines are included too.
*v_ic* *ic*
ic "inner comment", select current or next comment.
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
a comment marker, the line will be un-commented, if it doesn't, the line will
be commented out. Blank and empty lines are ignored.
depends on the range of lines to act upon. When all of the lines in range
have comment markers, all lines will be un-commented, if it doesn't, the lines
will be commented out. Blank and empty lines are ignored.
The value of 'commentstring' is the same for the entire buffer and determined
by its filetype (|filetypes|). To adapt it within the buffer for embedded

View File

@ -1,6 +1,10 @@
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*
gcc comment.txt /*gcc*
ic comment.txt /*ic*
o_gc comment.txt /*o_gc*
v_ac comment.txt /*v_ac*
v_gc comment.txt /*v_gc*
v_ic comment.txt /*v_ic*