Stack Exchange Network

Stack Exchange network consists of 175 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.

0
votes
1answer
19 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 // ...
1
vote
1answer
28 views

NeoVim: Single-Line Comments Also Format the Next Line [duplicate]

So, I started using NeoVim a little while ago and discovered a rather annoying quirk when using C++-style single-line comments // in source code of any language. Specifically, when you create a new ...
2
votes
1answer
34 views

Mapping to insert comment at the end of a line

I'm currently writing a plugin to quickly appends commented TODO: codetags to the end of a line in any file type. How can I make vim make use of it's commenstring feature to append a comment that ...
0
votes
0answers
19 views

How do I get Vim (with TComment) to do proper block comments in OCaml?

(I have TComment installed, and I'm on NeoVim 0.4.0.) Given this code, for example: let mem key st = let is_matching_key = function | Positional _ -> false | Flag f -> f.name == key ...
0
votes
1answer
32 views

How can I make Vimscript check if the current line has a comment?

I want to make a Python ftplugin (but other filetypes will also have this option) where, if the previous line has a comment that starts with #, the next line can be commented via <Shift><CR&...
1
vote
1answer
17 views

Vim doesn't extend Roxygen R comments

I'd like it if, when filling out my Roxygen comment snippet, #' Title #' #' @param #' #' @return #' #' @examples #' #' #' @export ...
2
votes
0answers
17 views

Applying full auto-format to comments but not code

I am considering using Vim's auto-format feature (i.e., adding a to formatoptions). However, I can't seem to figure out a combination of options that will give me the configuration that I want. For ...
1
vote
0answers
20 views

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

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
108 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
81 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
48 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
38 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
63 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
96 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
54 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
44 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
78 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
54 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
1answer
1k 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
37 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
74 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
86 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
497 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
131 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
339 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
975 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
50 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
69 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
198 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
122 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
524 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
535 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
119 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
127 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
288 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
140 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
51 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
120 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
641 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
80 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
268 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>&...
5
votes
2answers
4k 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
343 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
372 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
301 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
186 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
110 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
278 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
589 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. ...