0

I thought that text editors like vim took the # to indicate a comment and pass over those lines.

Here's the content of my ~/.vimrc file:

# Testing comments
set nocompatible

# Testing comments
set number

But when I run vim, I get this:

Error detected while processing /home/user/.vimrc:

line 1:
E488: Trailing characters: # Testing comments
line 4:
E488: Trailing characters: # Testing comments

When I remove the comment lines it works fine, but I should like to be able to add comments to my text files without it fouling things up. Does anyone know what I'm doing wrong?

Also, I read that I shouldn't use """, as this isn't really commenting. That and it is also for blocks.

Blair Conrad
  • 233,004
  • 25
  • 132
  • 111

2 Answers2

4

vim doesn't use # for comments; it uses quotation marks. Your .vimrc should read

" Testing comments
set nocompatible

" Testing comments
set number

By your comment regarding """, it seems you are confusing Python comments with Vim comments.

chepner
  • 497,756
  • 71
  • 530
  • 681
  • 2
    "*confusing Python comments with Vim comments*" ... not to mention confusing Python strings with Python comments. – Robᵩ Oct 16 '13 at 17:38
  • I got really confused when someone used hash comments in their vimrc from [this question](http://stackoverflow.com/q/1218390/266535). Thanks for clearing that up. – styfle Nov 08 '13 at 21:01
1

in .vimrc to write comments you have to use " your files would look like

" Testing comments
set nocompatible

" Testing comments
set number
Frederic Close
  • 9,389
  • 6
  • 56
  • 67