annotate runtime/pack/dist/opt/comment/doc/comment.txt @ 35056:79c73c4b3ecb

runtime(comment): include a simple comment toggling plugin Commit: https://github.com/vim/vim/commit/5400a5d4269874fe4f1c35dfdd3c039ea17dfd62 Author: Maxim Kim <habamax@gmail.com> Date: Fri Apr 26 19:53:13 2024 +0200 runtime(comment): include a simple comment toggling plugin fixes https://github.com/vim/vim/issues/14626 closes: https://github.com/vim/vim/issues/14634 Signed-off-by: Maxim Kim <habamax@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Fri, 26 Apr 2024 20:00:03 +0200
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
35056
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 *comment.txt* For Vim version 9.1. Last change: 2024 Apr 26
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4 VIM REFERENCE MANUAL
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6 Commenting and un-commenting text.
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 ==============================================================================
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 The comment.vim package, allows to toggle comments for a single line, a range
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 of lines or a selected text object. It defines the following mappings:
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 *gcc*
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14 gcc to comment/uncomment current line
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 *o_gc*
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 gc{motion} to toggle comments for the selected motion
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 *gcip*
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 gcip to comment/uncomment current paragraph
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19 *gcG*
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 gcG to comment/uncomment from current line till the end of a buffer
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21 *v_gc*
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 {Visual}gc to comment/uncomment the highlighted lines.
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 The plugin uses the buffer-local 'commentstring' option value to add or remove
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25 comment markers to the selected lines. Whether it will comment or un-comment
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26 depends on the first line of the range of lines to act upon. When it matches
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27 a comment marker, the line will be un-commented, if it doesn't, the line will
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28 be commented out. Blank and empty lines are not touched.
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30 If the mapping does not seem to work, chances are high, that this particular
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31 filetype is either not detected by Vim or the filetype plugin does not set the
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32 'commentstring' option.
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
34 You can simply configure this using the following autocommand (e.g. for legacy
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
35 Vim script): >
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
36
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
37 autocmd Filetype vim :setlocal commentstring="\ %s
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
39 This example sets the " as start of a comment for legacy Vim Script. For Vim9
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40 script, you would instead use the "#" char: >
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
41
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
42 autocmd Filetype vim :setlocal commentstring=#\ %s
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
43
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
44 ==============================================================================
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
45 Options:
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47 *g:comment_first_col*
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48 *b:comment_first_col*
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
49 By default comment chars are added in front of the line, i.e. if the line
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
50 was indented, commented line would stay indented as well.
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
52 However some filetypes require a comment char on the first column, use this option
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
53 to change default behaviour.
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
54
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
55 Use g:comment_first_col to change it globally or b:comment_first_col to
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
56 target specific filetype(s).
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
57
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
58 ==============================================================================
79c73c4b3ecb runtime(comment): include a simple comment toggling plugin
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
59 vim:tw=78:ts=8:fo=tcq2:ft=help: