Questions tagged [comments]

Comments are programmer-readable annotations in source code which are ignored by the parser.

Filter by
Sorted by
Tagged with
38
votes
11answers
5k views

How to comment out a set of lines which are selected in visual mode?

How do I comment out multiple in visual mode selected lines? How do I make it language specific? For example, if the first 4 lines are selected: def foo(a,b): for each in (a,b): print ...
59
votes
3answers
22k views

How can I get vim to stop putting comments in front of new lines?

I'm editing my .vimrc file, and I am including comments. When I have a comment like this: " example comment And then hit enter at the end of the line after finishing the comment, the next line is ...
11
votes
2answers
14k views

How to toggle comments with ctrl+/? [duplicate]

I'm coming from Atom, and with that I can highlight multiple lines and hit ctrl/ and it'll toggle comments for those lines. I how easy this is. Can I do something similar using ctrl/ with vim? I don'...
2
votes
1answer
2k views

Comment-out in vim with Shift-i not working

To comment out a block in vim, I enter visual mode with v or Control-v, select some lines, then hit I (Shift-i). However, I takes me out of visual mode and into Insert mode (which makes sense, as ...
1
vote
1answer
1k views

Toggling comments on and off

I have the following within my .vimrc: " toggle comments noremap <C-m> :<Left><Left><Left><Left><Left>exe "<Right><Right><Right><C-Right>&...
0
votes
1answer
124 views

use J to join comments

Imagine I have comments // line one // line two and I am on line one and want to join it with line two I will press J but that results in this: // line one // line two Instead of what I want // ...
15
votes
4answers
3k views

Adding 80-column wide comment header block with centered text

For some reason or another I often divide the code into subsections separated by headers like these: ################################################################################ ##################...
3
votes
1answer
316 views

Vim Comment Box Macro

I write comments of the form ############# ## Example ## ############# Always one line, always just like that. It's a way of breaking up code more visually. I have lately taken to the following way ...
8
votes
3answers
522 views

How can I create a /* comments section with /// like in XCode?

In XCode, there is an add-on called vvdocument, which can detect three / hits, and transfer /// into: /*! * @author Robbie Yi JIANG, 29-Jan-2016 14:01:45 * * */ How can I do this in Vim.
4
votes
3answers
5k views

Uncomment multiple lines

In vim I can use for instance 10j to go 10 lines down. And I can use . to repeat the last deletion. Now, in bash script I have many commented lines like this: # ... # ... # ... # ... # ... # ... # .....
7
votes
1answer
1k views

Is it possible to add inline comments in a multiline statement?

I have a function that looks like fu! MultiLineTest(u, v) if a:u != 2 && \ a:v != 2 return 'yes' else return 'no' end endfu Of course, the actual ...
5
votes
3answers
714 views

Making a custom function to comment out a range of lines

I want to make block commenting easy. To comment out a range of lines, what I can do is something like: :17,21s/^/# This will comment lines 17 to 21 in Python. But I don't want to write the whole ...
5
votes
4answers
1k views

How to generate patterns for comments?

As a way of organizing my codes, I like to include some titles as comments with specific patterns (I wish I can add ASCII art!). Consider for example, putting the following to mark a specific block of ...
3
votes
1answer
452 views

Vim "gq" command doesn't recognize Haskell-style comments

I have a Haskell file on VIM with a Haskell-style comment block: When I select that comment block on visual mode... And press gq, I expected VIM to format my comment to something like: But instead, ...
2
votes
2answers
113 views

How to disable auto insertion of comment header when pressing enter, but keep auto insertion of header when auto wrapping comment?

When editing c and cpp files, this is the behavior I want to achieve: When typing a comment line of the form // Line..., pressing <CR> should not add the comment header // in the next line. ...
2
votes
1answer
47 views

Check if vim is in a comment section

How can I check if the cursor is inside a comment section like this in C: /* * Comment section */ Or in python: """ Doc string """ # Comment line My idea for C is, ...
2
votes
1answer
258 views

What does Special Comment refer to in reference to a colorscheme?

I've recently delved into taking an existing colorscheme and customizing it to my liking. While doing this however, I found there was a highlight option for special comments and I'm not sure exactly ...
1
vote
2answers
309 views

Remove automatic comment leader

When I press return at the end of a comment line, vim will automatically insert the comment leader on the next line as well: // My comment bla bla // ‸ I like this feature and I would like to leave ...
1
vote
1answer
210 views

Comment highlight group does not work without reloading .vimrc

The following line in my ~/.vimrc: hi Comment ctermfg=gray does not take effect unless I start Vim and then use :source to reload .vimrc. As far as I can tell, all of the other hi commands work ...
1
vote
1answer
80 views

MatchIt not matching anymore if parenthesis, brackets, etc. are between quotes or in comments?

I upgraded to Ubuntu 18.04 and this has Vim version 8.0. This newer version has MatchIt setup to ignore parenthesis, brackets, etc. found inside comments and strings. Although it is at times useful, ...
0
votes
0answers
36 views

Marking/Annotating lines with symbols (with external storage)

When I audit code I perform a lot of annotations/mark lines. (what audited, by whom, if we have open issue, etc etc...). When I work with code I would like to mark lines (both individually and ranges),...