Questions tagged [comments]

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

Filter by
Sorted by
Tagged with
0
votes
0answers
9 views

How can I highlight Doxygen comments in italics, in C?

Currently in my .vimrc is: " C specifics autocmd BufRead,BufNewFile *.h,*.c set filetype=c.doxygen " italic comments highlight Comment cterm=italic This results in italic highlighting for ...
2
votes
1answer
36 views

Reformatting comments with gq, using spaces in 'comments'

I'm using Prettier to automatically reformat JavaScript (well, TypeScript, but same deal in this situation) source-code. It enforces a comment-style like this, with leading spaces replaced with ·: ···/...
0
votes
0answers
17 views

vim highlights the same occurence of a string and :nohl does not clear it

I have accidently pressed something and the string "#def" now always shows a white (as opposed to my regular dark) background: This occured while trying to comment out a function in python. ...
4
votes
0answers
68 views

How to get bold comments in vim

I am trying to add bold comments to my vim files. What i mean, is to be able to get something like this: I saw other articles like this that allow to toggle bold comment. The proposed solutions from ...
1
vote
1answer
84 views

Insert and remove a marker at the start of the current line

So, I'm trying to set up a sort of bookmark/marker kind of workflow, and I came to notice I'm used to put characters such as # and such for different meaning inside my own notes, etc. Now, I already ...
2
votes
1answer
41 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, ...
1
vote
1answer
21 views

Why does this pattern make :global work only on the first line of the highligted match?

\/\*.*\(\n\s\*.*\)*\n\s\*\/ is a pattern which I cooked up to match some multi-line C comments, i.e., in the format of: /* Comment Text * Comment Text * Comment Text */ Searching for the pattern ...
2
votes
1answer
44 views

Commentary with a Single Block

With Commentary I've set the commentstring for markdown: autocmd FileType markdown setlocal commentstring=<!--\ %s\ --> When I visually select the lines and gc a b c I get <!-- a --> <...
1
vote
2answers
314 views

Adding new filetypes with vim commentary

I'm trying to add include an unsupported filetype, gf, with vim commentary. The comments are simple, just prepend -- to any line, as in the Haskell tradition. According to the vim-commentary git, ...
0
votes
1answer
47 views

Change default character for comments

The assigned character for comments is " for vimscript. But i want to change it to some other character (like * or # for example). Based on this post, it seems like the string setlocal ...
1
vote
2answers
49 views

How to comment out only code lines and not existing comments

I use vim-commentary to comment. Hit g-c-c to toggle comments. But this will comment out the already existing comments if they start with // and it will comment out already existing comments startin ...
3
votes
2answers
63 views

Is there a way to insert documentation comments into a VIM macro definition?

I have found VI / VIM macros extremely obtuse to understand even a week after I've written them. The syntax of a .vimrc file supports comments on lines beginning with a doublequote character (") ...
0
votes
1answer
87 views

How are quotation marks used in this dotfile?

I'm a complete Linux beginner, trying to understand dotfiles. I've got the .vimrc dotfile, and tried to add the following command to the bottom: " <Ctrl-l> redraws the screen and removes ...
2
votes
1answer
38 views

bad comment behavior in cmake files

When I'm editing a cmake file in (neo)vim I'm getting bad behavior block inserting comment characters. Given this section of text install_license_file( PACKAGE tomcrypt TARGET ...
2
votes
2answers
97 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
34 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
49 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
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 ...
3
votes
1answer
158 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
193 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
64 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
162 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
46 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
536 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
194 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
76 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
38 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
143 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
104 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
99 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
114 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 // ...
2
votes
1answer
246 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
41 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
99 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
311 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&...
2
votes
1answer
82 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
26 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
33 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 ...
2
votes
1answer
1k 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
180 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
117 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
57 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
117 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
268 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
305 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
73 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
176 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
116 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)...
3
votes
1answer
11k 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
110 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 ...