How do I add a comment in Vim's configuration files, like .vimrc?
Asked
Active
Viewed 1.7e+01k times
448

Jonas Stein
- 6,826
- 7
- 40
- 72

alexchenco
- 53,565
- 76
- 241
- 413
4 Answers
591
A double quote to the left of the text you want to comment.
Example:
" this is how a comment looks like in ~/.vimrc
To be clear: Do not include a closing double quote. (See comment from Arslan Ali below.)

Wenfang Du
- 8,804
- 9
- 59
- 90

Myles
- 20,860
- 4
- 28
- 37
-
71And it shouldn't have a closing `"`. – Arslan Ali Mar 21 '15 at 10:12
-
5And it shouldn't be an inline comment, for inline (better: at-the-end-of-line comments) you can use `command foo |" my comment` (pipe for command separaion needed) – Hartmut Pfarr Sep 23 '19 at 20:03
141
"This is a comment in vimrc. It does not have a closing quote
Source: http://vim.wikia.com/wiki/Backing_up_and_commenting_vimrc

Arslan Ali
- 17,418
- 8
- 58
- 76

user3670292
- 1,519
- 1
- 9
- 3
-
2add a pipe before the double qoute if there is a command on the left of the comment – Hartmut Pfarr Sep 23 '19 at 20:04
14
Same as above. Use double quote to start the comment and without the closing quote.
Also, you can have command followed by comment in file .vimrc just like below:
set nu "display line number

Randy Lam
- 579
- 5
- 11