Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [comments]

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

1
vote
0answers
19 views

My C like Comments include markdown, can I have vim highlight those in my JavaScript (Node.js) code?

I write a lot of C/C++ and get highlighting for my Doxygen docs in my comments. It's not perfect, but it sure helps avoiding many very simple mistakes on the spot. To handle that, I simply have the ...
0
votes
1answer
49 views

How to add JavaScript and JSX comments in the same .js file

I've been using Neovim to do the majority of my dev work for most of 2018 however something that has eluded me is being able to quickly toggle JSX comments {/* JSX */} and regular Javascript ...
0
votes
1answer
48 views

Why does vim ignore commentstring when folding (foldmethod=marker)

I am editing a HTML document (filetype=html) in vim. foldmarker is set to {,}, foldmethod to marker and commentstring to <!--%s-->. When I visually select a region and use zf to create a ...
1
vote
1answer
43 views

How to delete Chinese characters in Lisp code (solved)

EDIT. Cause of problem has been found: the problem only appears when Tamas Kovacs' Paredit plugin is enabled. I have a lisp file containing comments and strings written using Chinese chracters. The ...
3
votes
1answer
37 views

Different color for comments with one # and two ## in python

I would like to know if there is some way to color different comments in python inside VIM. Today I use wombat256mod and I would like to color in red comments that start with double ## and color with ...
2
votes
1answer
56 views

Unable to repeat comment string for new line

Vim has the option to automatically continue comments when a new line is entered as described here. This currently works perfectly for // and # in .cpp and .python files respectively. I tried to add ...
3
votes
1answer
66 views

vim specific indentation for markdown

I want the indentation in markdown file as follows - [ ] Here is some text. When I press enter - [ ] <--- This entire thing should get populated. It means - [ ] should be copied onto the next ...
0
votes
1answer
45 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 ...
0
votes
1answer
42 views

Align Righthand Side Comments

I have a bunch of assembly code that needs commenting and I want to avoid having to space forward to make a comment every time just to align the comments. movq %rdi, %rdi # comment jne label ...
1
vote
1answer
64 views

Toggle comments

I'm trying to cerate a function who toggle a block of code into comments. I did this: " Commenting blocks of code. filetype on augroup commentgroup autocmd FileType c,cpp,java,scala let b:...
1
vote
1answer
43 views

Dynamically toggle formatoptions based on input

Question: Is there a way to control the indentation + comment leader input, when adding a new line? Details: I am trying to set formatoptions-=cro when inserting a new line (in specific syntax region)...
0
votes
0answers
17 views

Alter formatting behavior of comments in texfiles

While editing .tex files, I like to maintain a textwidth of 80 characters. And so I frequently do things like gqq to format a line after editing. But sometimes I've commented out something at the end ...
0
votes
1answer
318 views

How to comment a line in vim?

#inlcude<stdio.h> int main() { printf("Hello world\n"); } I want to comment line where the cursor is. For, example if I am on the line printf then I want to get following - #inlcude<...
1
vote
1answer
32 views

autocmd! tries to parse comment

The docs say: :autocmd adds to the list of autocommands regardless of whether they are already present. When your .vimrc file is sourced twice, the autocommands will appear twice. To avoid ...
1
vote
1answer
56 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 ...
0
votes
1answer
78 views

SpecialComment in vim

for example when i open vim appear ~ how SpecialComment, other example is when put :set list lcs=tab:\|\ appear the tabs how | SpecialComment but how do i insert SpecialComment using keyboard, it ...
0
votes
3answers
353 views

How can I return the current filetype's comment character in vimscript?

Simple question. I want to use the Tabular plugin to right-align end-of-line comments for arbitrary filetypes, and for that I need to write a simple nnoremap that uses the current filetype's comment ...
1
vote
3answers
129 views

Copy a line, comment it and replace a word in copied line

Libraries evolve all the time and I often face the situation where after an update some function name have changed and they return errors in the updated version of the library. It's easy to replace ...
0
votes
2answers
269 views

How to add inline comment for the echo command?

I've tried the following syntax: :echo 123 " comment but it failed with E15 and E114 errors. Is there any way to put the inline comment right after the command, so it can be ignored?
1
vote
2answers
736 views

vim comment out every line of text containing a pattern using the 'global' command

In my file containing latex source code, I wish to comment out all the lines matching a pattern (specifically, the pattern that I am interested in is \draw, including the \ character). I have magic ...
2
votes
0answers
49 views

Syntax highlighting depending on whether whole line is commented

Is it possible to have vim highlight folds differently depending on whether every line in a fold is only comments or whitespace? In that case, how?
6
votes
0answers
65 views

Comments pane for current buffer that you can jump to such as TODO:, WARN:, and NOTE:?

A while ago I used to use eclipse as my IDE, and I remember you could add TODO: some task, NOTE: some comment, WARN: some warning to your code, and it would appear in a particular pane for the current ...
3
votes
1answer
158 views

How do I highlight pc-lint comments in C/C++

How do I mimic the behavior of Doxygen comment highlighting for PC-lint comments? Comments are in the following formats: /*lint ... */ //lint ... /* LINTLIBRARY */ /* ARGUSED */ /* VARARGS[N] */ <-...
3
votes
0answers
102 views

Possible to exclude comments from textwidth?

I recently discovered the textwidth setting, which lets me configure vim to insert a "smart" whitespace-delimited carriage return as I'm typing when my line of text exceeds my specified limit. Is ...
1
vote
1answer
407 views

Disable absolutely all auto-comments, for real

Auto-comments are the most annoying "feature" of text editors and IDEs for me. I've searched -- nay, scavenged -- high and low to figure out how to get rid of literally any semblance of automatic ...
4
votes
2answers
1k 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: # ... # ... # ... # ... # ... # ... # .....
4
votes
1answer
397 views

Uncomment multiline block with NERDCommenter

Is it possible using NERD-commenter to uncomment a multiline block under the cursor without selecting the entire block visually first? If no, are there any better plugins, that can do the job? Here ...
0
votes
1answer
112 views

Control indenting of Ruby Comments

I use Vim to edit Ruby code, and the one issue that I keep having trouble with is the comment indenting. It seems that Vim really wants all # comment marks that begin a line to indent all the way to ...
1
vote
1answer
102 views

Enable templating language (e.g., Liquid) syntax highlighting but keep native (html/css) commenting?

I just started working with Jekyll, which uses Liquid. As a templating language, Liquid is embedded into files of other types (e.g., HTML, CSS, or Markdown). Vim handles this sort of dual syntax ...
4
votes
1answer
285 views

How to comment a line directly from bash using vim?

What I usually do from bash/vim ... is open file with vim go to line to comment comment a line save and quit My file is /usr/local/etc/php/7.0/conf.d/ext-xdebug.ini and the initial content is [...
1
vote
0answers
136 views

Indentation in three piece comments in javascript

I use Vim 7.4.2149 and the plugin pangloss/vim-javascript for js indentation. I need to get comments like: /* * */ But instead I get: /* * * */ I'm not really interested in syntax ...
2
votes
1answer
49 views

Edit width-limited comment blocks faster

Take any long comment in paragraph form: 1 // This is a comment that is really long because it is describing something 2 // worth being verbose about, possibly at the beginning of the program (...
5
votes
1answer
108 views

gqip for VHDL comments does not work

After I set syntax=vhdl and set fo=tcq, running gqip on the following paragraph does not work as expected: -- Lorem ipsum dolor sit amet, -- tempor incididunt ut labore et dolore magna aliqua. Ut ...
3
votes
0answers
568 views

Configure custom key mapping for commenting

I am using https://github.com/scrooloose/nerdcommenter/ plugin to comment the code. It's working fine, but I would like to do a modification. Currently these are the default mappings: <leader>...
3
votes
2answers
77 views

Break long comments

Given the file alfa.c: // Lorem ipsum dolor sit amet, apeirian constituam interpretaris no his, soluta salutandi persequeris vel ne, facete impedit contentiones te eam. Ut utamur habemus qualisque ...
1
vote
1answer
196 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>&...
4
votes
2answers
3k 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'...
5
votes
3answers
298 views

How do I comment out lines without changing indentation?

I use Vim to write my Python source and use the debugging library pdb. Let's say I have this code with break points commented out: import pdb #pdb.set_trace() def func1(): #pdb.set_trace() ...
0
votes
2answers
278 views

How can I change/delete comments easily?

For commenting and uncommenting I now use the vim-commentary plugin, also the NERD commenter can be used as mentioned in: How to comment out a set of lines which are selected in visual mode? I would ...
9
votes
3answers
281 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
1answer
155 views

Automatic comment leader not inserted on some file types

My formatoptions include cro. I have a filetype (Stata .do files) in which the comment character is *. Anything after this character is considered a comment line. In insert mode *<CR>* leads ...
5
votes
1answer
108 views

Is it possible to put vim comments in lines that include `iabbrev`

Is it possible to put vim comments in lines that include iabbrev, as in: iabbrev hte the " common typo
5
votes
1answer
242 views

A plugin to align comments

I often edit code where I have a general comment for a block of code and specific comment for each line. For instance, this a sample of my .vimrc. "indentation set autoindent "...
1
vote
2answers
516 views

visual mode gq not reflowing comment block

I am looking for an easy way to reflow blocks of comments (in GO). According to this post I should be able to just run gq on a block and it will reflow automatically, but this doesn't seem to work. ...
8
votes
2answers
2k views

Hide certain lines completely (not folding)

I would like to be able to hide certain lines in my buffer from showing up at all (and being able to toggle seeing them). I found similar questions, but they don't solve my problem. I don't want to ...
2
votes
1answer
282 views

Folding my .vimrc doesn't work as expected

To structure my .vimrc a bit better I decided to create a custom fold expression in the file .vim/after/ftplugin/vim/folding.vim which gets loaded automatically for my .vimrc: " The purpose of this ...
1
vote
2answers
198 views

Comment line into a box and undo

What I want I want create a mapping which comments a line into a box, for example textline shall be transformed to " ############################################################################## "...
3
votes
0answers
98 views

Formatting blocks of “commented out” text

I would like to be able to edit and format blocks of comments (in different markup and programming languages) as if the commenting characters (generally in the beginning of the lines) are ignored. ...
5
votes
3answers
333 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 dont want to write the whole ...
3
votes
1answer
60 views

vim tcomment plugin changes the hyphens in untagged text (html) to html code (& #45;)

When editing html in vim, I'll write the class name of the section that I am working on like this: mid-med It is untagged plain text. I'll call tcomment to comment that out. What I expect to have ...