Operating System - HP-UX
1833903 Members
1951 Online
110063 Solutions
New Discussion

Re: comment command in VI editor

 
Ed Grover
New Member

comment command in VI editor

What is the command to comment or remark out lines in a file on linux.
7 REPLIES 7
Pete Randall
Outstanding Contributor

Re: comment command in VI editor

You mean putting a pound sign (#) in front of the line?

Pete

Pete
Rodney Hills
Honored Contributor

Re: comment command in VI editor

Which would typically be a shell script or certain /etc files.

-- Rod Hills
There be dragons...
Ed Grover
New Member

Re: comment command in VI editor

That didn't seem to work although that is what the vi commands book told me to use. This is a bb-host file running on the big brother app and it is sending it to me every 15 minutes. I could delete the line but would like to put the line back in so just commenting it out seemed like a good idea.
Uday_S_Ankolekar
Honored Contributor

Re: comment command in VI editor

Try ; (semi colon) instead.
Good Luck..
Christopher McCray_1
Honored Contributor

Re: comment command in VI editor

Hello,

This may be a long shot, but I think maybe worth mentioning. Some applications, for example, measureware, use an asterisk (*) as a comment marker in certain files. You should consult the docs concerning the application to see if this is the case.

Chris
It wasn't me!!!!
Wodisch_1
Honored Contributor

Re: comment command in VI editor

Hi,

since I do not get your point, I may be wrong...
If you have a ".exrc" file to be *executed* by your "VI" and you are looking for a way to have comments in there, then the character your search is the double-quote.

As an example:

$HOME/.exrc
:set autoindent showmode
":set number
:map #1 :!man vi^V^M

If you have that in your $HOM E directory and start "VI", then it will run with automatic indentation, will show wether it is insert mode or not, but will NOT show line-numbers. And funciton key "F1" will map to "man vi" (only in command mode, of course).

HTH,
Wodisch
Misa
Frequent Advisor

Re: comment command in VI editor

Ed, the answer to your question depends on what kind of file you're editing.

Files are intended to be read by different utilities or applications. Each utility or application has been programmed to accept some sequence of characters as a "remark" or "comment" (meaning "ignore this line or part of the line").

Some common characters:

- C/Bourne/Korn shell uses the pound/number/hash sign #
- named.conf uses a semicolon ;
- SQl uses "rem"
- C uses /* */

In response to your reply, I guess the answer is find out what comment string the programmers used for your application.