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
2 answers
428 views

Conceal comments in Vim/Neovim

I am writing a lot of latex and would like to conceal comments. There are often several lines of text that I comment but would like to keep/not delete. Concealing comments explained: A comment is ...
baxbear's user avatar
  • 314
0 votes
0 answers
19 views

Creating a better ftplugin for rmarkdown

The Rmarkdown files have markdown formatting interspersed with R language chunks, denoted as follows: # markdown header markdown regular text ```{r} # comment: some R code... a <- pi * r^2 ``` ...
January's user avatar
  • 263
0 votes
1 answer
20 views

How can add the comment lines when call function?

I want to add shebang when creating anew python file. .vimrc: autocmd BufNewFile *.py exec ":call SetTitle_py(0)" func SetTitle_py(line_num) let boilerplate = [ \"#!/usr/bin/...
showkey's user avatar
  • 1,104
0 votes
2 answers
35 views

Why the comment can't be set at the second line instead of first line?

I want to add some comment lines when to edit python file: vim .vimrc autocmd BufNewFile *.py exec ":call SetTitle_py()" func SetTitle_py() call append(line("."), "#...
showkey's user avatar
  • 1,104
2 votes
1 answer
42 views

:.w !bash a temporarily modified line and executing it in the shell

#!/usr/bin/env bash # scp /tmp/abc.sh SERVER1:~/bin && ssh SERVER1 "~/bin/abc.sh" echo "Hello Stack Exchange" echo "thanks for the help I would like to be able to use ...
Aaron Burda's user avatar
0 votes
0 answers
201 views

block comments not automatically indented in Neovim

When inserting a block comment in a (TypeScript) buffer in Neovim, the line after the /**<Return> is not automatically indented. How can I achieve the expected behavior described below? Neovim ...
KIYZ's user avatar
  • 101
1 vote
0 answers
44 views

Stop foldmarker inserting hash

I my folds are set with foldmarker={{{,}}}. When I create a fold it inserts a comment # char before the marker. So it inserts #{{{. How do I stop it doing this? I have syntax highlighting (and it ...
markling's user avatar
  • 319
2 votes
1 answer
41 views

A question about the comment for comment shell command

When I read the comment help file, I found It is not possible to add a comment to a shell command ":!cmd" or to the ":map" command and a few others (mainly commands that expect ...
lizhe's user avatar
  • 137
0 votes
1 answer
473 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....
Qix - MONICA WAS MISTREATED's user avatar
2 votes
1 answer
330 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"...
serii 's user avatar
  • 59
0 votes
0 answers
22 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 ...
Julius H.'s user avatar
  • 239
0 votes
1 answer
324 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 ...
Stefan's user avatar
  • 179
0 votes
0 answers
51 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),...
Grzegorz Wierzowiecki's user avatar
3 votes
1 answer
183 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 ·: ···/...
ELLIOTTCABLE's user avatar
6 votes
0 answers
494 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 ...
needle's user avatar
  • 181
1 vote
1 answer
98 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 ...
Nordine Lotfi's user avatar
2 votes
1 answer
150 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, ...
TornaxO7's user avatar
  • 561
1 vote
1 answer
36 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 ...
Monke's user avatar
  • 13
2 votes
1 answer
114 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 --> <...
laktak's user avatar
  • 2,898
2 votes
2 answers
2k 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, ...
Warrick Macmillan's user avatar
0 votes
1 answer
610 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 ...
Nordine Lotfi's user avatar
1 vote
2 answers
124 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 ...
Salahuddin Ahmed's user avatar
3 votes
2 answers
233 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 (") ...
August's user avatar
  • 141
0 votes
1 answer
227 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 ...
Lou's user avatar
  • 103
2 votes
1 answer
76 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 ...
ryan0270's user avatar
  • 123
2 votes
2 answers
190 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. ...
Diggs's user avatar
  • 75
1 vote
2 answers
51 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 ...
gfe's user avatar
  • 245
1 vote
2 answers
71 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 ...
noibe's user avatar
  • 179
4 votes
1 answer
6k 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 ...
Joshua Fox's user avatar
3 votes
1 answer
162 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', ...
0az's user avatar
  • 133
2 votes
1 answer
456 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 ...
jth's user avatar
  • 123
1 vote
1 answer
70 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 ...
ELLIOTTCABLE's user avatar
3 votes
3 answers
382 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 ...
Throckmorton's user avatar
1 vote
1 answer
60 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 "...
ka3ak's user avatar
  • 261
6 votes
3 answers
822 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 # ############## ...
Flame_Phoenix's user avatar
2 votes
0 answers
375 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 ...
Giorgio Robino's user avatar
1 vote
1 answer
150 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, ...
Alexis Wilke's user avatar
0 votes
0 answers
133 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 <...
Byron Hawkins's user avatar
0 votes
1 answer
363 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 ...
Yves's user avatar
  • 983
2 votes
1 answer
172 views

Vim and enhanced commentify 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 ...
Jacques's user avatar
  • 21
1 vote
1 answer
210 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&...
Jacktose's user avatar
  • 843
1 vote
1 answer
202 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 // ...
theonlygusti's user avatar
  • 2,219
2 votes
1 answer
911 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 ...
Anadian's user avatar
  • 23
2 votes
1 answer
69 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 ...
Benjamin Chausse's user avatar
0 votes
0 answers
153 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 ...
ELLIOTTCABLE's user avatar
0 votes
1 answer
560 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&...
Paul Kim's user avatar
  • 231
2 votes
1 answer
113 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 ...
brandones's user avatar
  • 123
2 votes
0 answers
45 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 ...
sasquires's 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 ...
Alexis Wilke's user avatar
5 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 ...
ipatch's user avatar
  • 1,839