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
0 answers
26 views

How do you disable all magic comment formatting in neovim?

I recently switched to Neovim's new LSP setup instead of the old Vim-based language plugins and now I get this incredibly annoying comment "helper" behavior when I hit enter after a /** in e....
user avatar
1 vote
1 answer
87 views

How to comment html in php file in vim?

I use this plugin for comments. Plug 'tpope/vim-commentary' And when I comment html code in php I get /* <div class="our-photos"> */ /* <h2 class="our-photos__main-title"...
user avatar
  • 15
0 votes
0 answers
18 views

Plug-in to create comment layer

Is there any plug-in where you can write text without being in insert mode but it’s not being written to the actual file? If you enter insert mode, all that comment text disappears. It should be in a ...
user avatar
0 votes
1 answer
26 views

Automatic removal of indent in markdown (fenced) codeblock comments starting with #

When writing indented fenced codeblocks (the only ones I use) like ```sh some shell code ``` in markdown the indentation of comments is automatically removed when I type the comment ...
user avatar
  • 169
0 votes
0 answers
27 views

How to make spell ignore all Comment groups?

I am using gruvbox color theme which wasn't showing spell mistakes in terminal so I had to overwrite SpellBad. My method of doing this is this: function! MyHighlights() abort hi SpellBad term=NONE ...
user avatar
0 votes
0 answers
39 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),...
user avatar
0 votes
0 answers
64 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 ...
user avatar
  • 101
3 votes
1 answer
73 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 ·: ···/...
user avatar
5 votes
0 answers
149 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 ...
user avatar
  • 171
1 vote
1 answer
92 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 ...
user avatar
2 votes
1 answer
74 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, ...
user avatar
  • 446
1 vote
1 answer
22 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 ...
user avatar
  • 13
2 votes
1 answer
65 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 --> <...
user avatar
  • 2,663
2 votes
2 answers
684 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, ...
user avatar
0 votes
1 answer
179 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 ...
user avatar
1 vote
2 answers
57 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 ...
user avatar
3 votes
2 answers
143 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 (") ...
user avatar
0 votes
1 answer
147 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 ...
user avatar
  • 103
2 votes
1 answer
57 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 ...
user avatar
  • 123
2 votes
2 answers
143 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. ...
user avatar
  • 55
1 vote
2 answers
40 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 ...
user avatar
  • 225
1 vote
2 answers
59 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 ...
user avatar
  • 149
2 votes
1 answer
3k 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 ...
user avatar
3 votes
1 answer
160 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', ...
user avatar
  • 133
2 votes
1 answer
268 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 ...
user avatar
  • 23
1 vote
1 answer
66 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 ...
user avatar
3 votes
3 answers
265 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 ...
user avatar
1 vote
1 answer
54 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 "...
user avatar
  • 249
5 votes
2 answers
639 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 # ############## ...
user avatar
1 vote
0 answers
241 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 ...
user avatar
1 vote
1 answer
87 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, ...
user avatar
0 votes
0 answers
68 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 <...
user avatar
0 votes
1 answer
206 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 ...
user avatar
  • 883
2 votes
1 answer
128 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 ...
user avatar
  • 21
1 vote
1 answer
148 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&...
user avatar
  • 753
1 vote
1 answer
143 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 // ...
user avatar
  • 1,707
2 votes
1 answer
415 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 ...
user avatar
  • 23
2 votes
1 answer
49 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 ...
user avatar
0 votes
0 answers
123 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 ...
user avatar
0 votes
1 answer
431 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&...
user avatar
  • 221
2 votes
1 answer
96 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 ...
user avatar
  • 123
2 votes
0 answers
33 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 ...
user avatar
  • 121
1 vote
0 answers
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 ...
user avatar
3 votes
1 answer
2k 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 ...
user avatar
  • 1,559
0 votes
1 answer
217 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 ...
user avatar
0 votes
1 answer
147 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 ...
user avatar
  • 811
3 votes
1 answer
143 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 ...
user avatar
  • 33
2 votes
1 answer
140 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 ...
user avatar
  • 123
3 votes
1 answer
334 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 ...
user avatar
3 votes
1 answer
337 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 ...
user avatar
  • 475