The # sign seems to have stopped functioning. Below is a copy of the .exrc file for vim (a\s:
# X
# X # This is the .exrc Configuration file for antiX
# Wed. 26 Sept 2012
set nu
syntax enable
colorscheme evening
set shiftwidth=4
set tabstop=4
set autoindent
~
and here is what I get when I run 'vim .exrc':
vim .exrc
Error detected while processing /home/dmk-antiX/.exrc:
line 1:
E488: Trailing characters: # X
line 2:
E488: Trailing characters: # X # This is the .exrc Configuration file for antiX
line 3:
E488: Trailing characters: # Wed. 26 Sept 2012
Press ENTER or type command to continue
ie. the system is not recognizing the hash. It does NOT seem to occur on files which already exist - I can edit .bashrc for instance and all the comments are fine - only with new files.
I've tested on SuSE 12.1 (which powers my Samsung i5), on antiX & Mint running on Vbox and on a live disk of SuSE 12.2. They all seem to show the same behaviour.
Does anyone have any ideas?
topic title: Problem with #'d Comments
7 posts
• Page 1 of 1
-
Posts: 137
- Joined: 19 Sep 2012
-
Posts: 1,308
- Joined: 31 Aug 2009
#2
Vim does not use the hash mark (#) for starting a comment line. Try using a double-quote (") instead.
-
Posts: 137
- Joined: 19 Sep 2012
#3
BitJam - Thanks for the tip but you're wrong about, what we in the UK call, the 'hash' but is known as the 'pound' sign in the US. Some time, towards the end of the last Millenium, when I first came accross Linux I got a copy of Linux for Dummies. Not a very useful book, but that & Unix in a Nutshell (O'Reilly hadn't done the Linux version then) was what I started off with.
Being a grade A hoarder I went into my office (a shed at the foot of my garden) & dug it out. And here it is, at the foot of page 175:
"The first line is a comment line. It is preceded by a pound sign (#) or hash marks (//) - both tell Linux to ignore the line." ------------"Be sure" ----------"you remove the comment marks (#,//). Otherwise Linux ignores the entry -----"
I'd forgotten all about //. I don't think I've ever seen it used. I tried it today & it doesn't seem to work. The double quote (") seems to work on antiX. I wrote test file - using vim as the editor & # for comments - on Mint and the reults were as already recorded. I repeated it all using Kate & the # worked fine!
For scripting, I have always used vim as my editor of choice, I have always used the # for comments andI have scripts I wrote over twelve years ago which have never caused any trouble (well - some of them did when I was writing them). I thoughht initially that the problem might be - not with vim, but - with the way the system was interpreting the #. I'm not so sure now.
It's all very odd!
Being a grade A hoarder I went into my office (a shed at the foot of my garden) & dug it out. And here it is, at the foot of page 175:
"The first line is a comment line. It is preceded by a pound sign (#) or hash marks (//) - both tell Linux to ignore the line." ------------"Be sure" ----------"you remove the comment marks (#,//). Otherwise Linux ignores the entry -----"
I'd forgotten all about //. I don't think I've ever seen it used. I tried it today & it doesn't seem to work. The double quote (") seems to work on antiX. I wrote test file - using vim as the editor & # for comments - on Mint and the reults were as already recorded. I repeated it all using Kate & the # worked fine!
For scripting, I have always used vim as my editor of choice, I have always used the # for comments andI have scripts I wrote over twelve years ago which have never caused any trouble (well - some of them did when I was writing them). I thoughht initially that the problem might be - not with vim, but - with the way the system was interpreting the #. I'm not so sure now.
It's all very odd!
-
Posts: 1,308
- Joined: 31 Aug 2009
#4
I thought you were asking about scripts for Vim such as .vimrc. The content of the .exrc file you posted looks like a Vim script. Vim scripts use double quotes (") instead of hash marks (#) for starting comment lines.
If you don't believe me just Google(vimrc comments). For example
========= SCRAPER REMOVED AN EMBEDDED LINK HERE ===========
url was:"http://www.linuxfromscratch.org/blfs/view/svn/postlfs/vimrc.html"
linktext was:"http://www.linuxfromscratch.org/blfs/vi ... vimrc.html"
====================================
says:
If you don't believe me just Google(vimrc comments). For example
========= SCRAPER REMOVED AN EMBEDDED LINK HERE ===========
url was:"http://www.linuxfromscratch.org/blfs/view/svn/postlfs/vimrc.html"
linktext was:"http://www.linuxfromscratch.org/blfs/vi ... vimrc.html"
====================================
says:
Note that the comment tags are" instead of the more usual # or //. This is correct, the syntax for vimrc is slightly unusual.
-
Posts: 137
- Joined: 19 Sep 2012
#5
BitJam - sorry about the rather surly silencce from this end. I've had 'an infection of the eye' which the Quack's been treating with something greasy - the upshot was that even seeing a computer keyboard was hard enough, reading the screen was almost impossible. I hve been hors de combat computerwise for a few days.
I have to admit, I feel a complete plonker for my mistake. My core distro, SuSE, has always taken care of syntax Etc. Although I have used vim for years, I have never moved much beyond the ex commands & regex's - usually any help I need can be found in the Quickref. I'm now starting to work my way thru' the Users Manual.
Thanks for your help'
dmk
I have to admit, I feel a complete plonker for my mistake. My core distro, SuSE, has always taken care of syntax Etc. Although I have used vim for years, I have never moved much beyond the ex commands & regex's - usually any help I need can be found in the Quickref. I'm now starting to work my way thru' the Users Manual.
Thanks for your help'
dmk
-
Posts: 1,139
masinick - Joined: 26 Apr 2008
#7
FWIW, I can confirm in vim (or GVim) that a Vim comment character is the" rather than the #. I confirmed this by running GVim, then typing the command :h comment
I found this immediately:
*:quote* *:comment*
'"' at the start of a line causes the whole line to be ignored. '"'
after a command causes the rest of the line to be ignored. This can be used
to add comments. Example:
:set ai"set 'autoindent' option
It is not possible to add a comment to a shell command":!cmd" or to the
":map" command and a few others, because they see the '"' as part of their
argument. This is mentioned where the command is explained.
I found this immediately:
*:quote* *:comment*
'"' at the start of a line causes the whole line to be ignored. '"'
after a command causes the rest of the line to be ignored. This can be used
to add comments. Example:
:set ai"set 'autoindent' option
It is not possible to add a comment to a shell command":!cmd" or to the
":map" command and a few others, because they see the '"' as part of their
argument. This is mentioned where the command is explained.