Results 1 to 3 of 3
I used UNIX years ago and need to get back into it a little. When I use vi to open some of my old files I see that I used ...
- 01-05-2012 #1Just Joined!
- Join Date
- Dec 2011
- Posts
- 6
Question on vi comments
I used UNIX years ago and need to get back into it a little. When I use vi to open some of my old files I see that I used the pound sign (#) to comment lines. However, for some reason, the pound sign does not work in my .exrc file, it causes a hic cup. However, a double quote (") works. I've done some searching but have not been able to determine the rules for commenting. Any help would be appreciated.
Thanks,
Ken
- 01-06-2012 #2Linux Guru
- Join Date
- May 2011
- Posts
- 1,838
Are you sure that the pound signs were not for bash/sh scripts that you were editing *with* vi? The comment character is definitely a " at any rate (go here and scroll about 2/3 of the way down, or look for COMMENTS - all caps).
Anyway, the .exrc file does not work with my current vim, maybe it has been replaced by ~/.vimrc (which definitely does work)?
As per the link above, do :help vimrc in a vi session to read more on the comment character.Last edited by atreyu; 01-06-2012 at 01:45 AM. Reason: link
- 01-06-2012 #3
First of all, using raw "vi" is pretty rare these days. It's more likely that you're using Vim (vi improved), which follows some different rules, including using ~/.vimrc as its resource file.
Every programming language uses different comment characters. Shell scripting (sh, bash, zsh) and many other scripting languages (e.g. Perl, Ruby, Python) use "#" to indicate that the remainder of the line is a comment. C-based languages (e.g. C, C++, Java) use // for this purpose, or /* */ to make a bounded area comments.
vi (and likewise Vim) uses " as its comment character instead of "#".DISTRO=Arch
Registered Linux User #388732


Reply With Quote