Questions tagged [comments]

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

Filter by
Sorted by
Tagged with
2
votes
2answers
29 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. ...
1
vote
2answers
21 views

Autoindent unordered lists that start with a hyphen in cpp files

The context I've the following options in my vimrc set formatoptions=cnroqj set textwidth=80 When editing tex files, lines whose content is longer than &textwidth is splitted and formatted as ...
1
vote
2answers
22 views

Defining a color to be the same color of comments

I'm using the indentLine plugin to display line indents with a continuos vertical line, and I'd like to set the color of that line to the same color of my comments. To get the foreground color of my ...
2
votes
1answer
68 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 ...
3
votes
1answer
134 views

Commenting out an element of a multiline list

Is it possible to comment out one element of a multiline list? Or, in general, can you combine line continuations with comments? (Lightly modified from my vimrc) [ \'eslint', \'tsserver', ...
1
vote
1answer
59 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
61 views

Automatically fold particular content, in any filetype

I often find myself patching projects that add a relatively big (23 lines out of a 37-line file? ) license-header to every. single. file. Is there a plugin or straightforward way I can add a global ...
3
votes
3answers
74 views

Pretty python comments

I comment sections in python via a centered title surrounded by #. What I would like is to make a command so that I can automatically generate such headers. For example, to generate a line like the ...
1
vote
1answer
39 views

Are there comments in command-line mode?

Does VIM support comments in command-line mode? I have tried the most popular variants including .VIMRC comments but neither worked: :echo "hello" // echo usage :echo "hello" /* echo usage */ :echo "...
5
votes
2answers
273 views

Create indented comment box vim

Background I have a code file and I like to place comments inside my code. Sometimes, these comments are boxed: defmodule BananasModule do ############## # Public API # ############## ...
1
vote
0answers
62 views

Javascript syntax-highlight for JsDoc comments

I now use plugin vim-javascript just to have a nice syntax highlight for JsDoc comments in my Javascript files. vim-javascript provides nice colors highlight but it conflict with all parentheses ...
1
vote
1answer
57 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
23 views

Auto-insert C++ comment only on <shift+enter>

The comment auto-insert feature is often very helpful and otherwise very annoying, depending on the kind of comment I am writing. Is it possible to bind the auto-insertion of // exclusively to <...
0
votes
1answer
81 views

How to set a shortcut for multiple leader commands

I'm using the nerdcommenter to comment and uncomment my c++ code. Basically I use \cc to comment one line, \cu to uncomment, \ca to switch the delimiters (switch // to /**/ or switch back). Now I ...
1
vote
1answer
70 views

vim and enhancedcommentify weird behavior for C

I am trying to use EnhancedCommentify plugin for vim and mostly using C. However I can't figure out the issue but when I comment/uncomment it uses (* ---- *) instead of /* ----- */. I tried to change ...
1
vote
1answer
53 views

Alert sound when using <C-L> etc. mappings

I've got these mappings in my .vimrc: nnoremap <C-Tab> :tabn<cr> " cycle tabs nnoremap <C-S-Tab> :tabp<cr> " cycle tabs backward nnoremap <C-J> <C-W><C-J&...
0
votes
1answer
44 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
114 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
38 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
70 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
116 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
43 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
24 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
25 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
562 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
131 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 ...
0
votes
1answer
81 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
49 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
84 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
171 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 ...
3
votes
1answer
204 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
50 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
116 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
82 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)...
1
vote
1answer
6k 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
76 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
2answers
171 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
167 views

SpecialComment in vim

When I open vim, the ~ representing no lines are highlighted according to SpecialComment. So too are the characters in 'listchars' (e.g, :set list lcs=tab:\|\). How can I insert text that is ...
2
votes
3answers
808 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
136 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 ...
1
vote
2answers
615 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
2k 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?
5
votes
0answers
84 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 ...
2
votes
1answer
291 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] */ <--...
2
votes
0answers
159 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
833 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 ...
3
votes
2answers
3k 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: # ... # ... # ... # ... # ... # ... # .....
5
votes
1answer
1k 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
135 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 ...