How to put the comments to 50 lines, using vi editor?

Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to put the comments to 50 lines, using vi editor?
# 1  
Old 02-08-2008
How to put the comments to 50 lines, using vi editor?

Hi All,

Please let me know how I can put a comment (e.g // or #) to more than 50 lines using vi editor in a .cpp/.sh file.

Thanks in advance.
# 2  
Old 02-08-2008
maybe like this

for example

.,+50s/^/#/ where
. is current line
+50 is fifty lines from the current



11 first line
61 last line to insert..

or if you want to add at the end of the line replace ^ with a $
# 3  
Old 02-08-2008
Thank you very much. And how about the cpp spesific comments ('//') ?
# 4  
Old 02-08-2008

when you want to use the cpp comments (or other special characters) you need to escape them:


the escape character is a \
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Put in one line only the lines with digits

Hello, I haven't been here for a while and I might be forgetting some things. I have an input text like this titleA http://myurl/bla/blabla/1234 http://myurl/bla/blabla/6789 titleB http://myurl/bla/blabla/5678 http://myurl/bla/blabla/1234 titleC http://myurl/bla/blabla/9123... (10 Replies)
Discussion started by: Kibou
10 Replies

2. Shell Programming and Scripting

Grep last two lines, calc & adding comments

....... 06/09/2013|12:00:00 PM|3|26112|40|44032|27419.7|6 1 0 93 |6|1|0|93 06/09/2013|12:30:00 PM|3|26112|40|44032|27491|11 4 0 85 |11|4|0|85 I have "sysperf.out" file containing the lines above. What I like to have on the output is: Node: prod1db ===> this is the hostname Date:... (7 Replies)
Discussion started by: Daniel Gate
7 Replies

3. Shell Programming and Scripting

Please Help! Need to put the lines of a txt to one line

Hi all, I'm quite newbie in shell scripting but I found a problem what I cant solve. I have a .txt file which looks like this: /22/ /23/ /24/ and so on and I'd need to make it look like this: /22/|/23/|/24/|...and so on. these numbers are growing and has lines like this /2a/ as well.... (15 Replies)
Discussion started by: gergo235
15 Replies

4. What is on Your Mind?

Fun things to put in comments in scripts?

Approaching the end of my portion of some STIG/DOD compliance automation and I was challenged by a co-worker to include a story in my code. There are blocks of code that need to be kept the way they are for GIT/Gerrit and then compliance, but otherwise I changed out all the comments into a... (2 Replies)
Discussion started by: Vryali
2 Replies

5. Shell Programming and Scripting

Perl XML, find matching condition and grep lines and put the lines somewhere else

Hi, my xml files looks something like this <Instance Name="New York"> <Description></Description> <Instance Name="A"> <Description></Description> <PropertyValue Key="false" Name="Building A" /> </Instance> <Instance Name="B"> ... (4 Replies)
Discussion started by: tententen
4 Replies

6. UNIX for Dummies Questions & Answers

Remove blank lines and comments from text file

Hi, I am using BASH. How can I remove any lines in a text file that are either blank or begin with a # (ie. comments)? Thanks in advance. Mike (3 Replies)
Discussion started by: msb65
3 Replies

7. Shell Programming and Scripting

Sed script, changing all C-comments to C++-comments

I must write a script to change all C++ like comments: // this is a comment to this one /* this is a comment */ How to do it by sed? With file: #include <cstdio> using namespace std; //one // two int main() { printf("Example"); // three }//four the result should be: (2 Replies)
Discussion started by: black_hawk
2 Replies

8. UNIX for Advanced & Expert Users

Add Comments to the specifi lines i na file

I have a requirement like below.I need to Comment some lines in a file. File contains following information. { attribute1 attribute2 atrribute3 attribute4 attribute5 attribute6 attribute7 } I have a requirement like some times i need to comment lines 3 to before '}' and some... (1 Reply)
Discussion started by: ukatru
1 Replies

9. Shell Programming and Scripting

Put two lines into one from file

Hello, I have a script that generates the following file named /tmp/rfkill: rf55 pts/13 Jul 10 06:38 ( 15782 pts/13 5:07 b rf56 pts/15 Jul 10 06:53 ( 18552 pts/15 0:28 b rf55 pts/39 Jul 10 09:12 ( 19354 pts/39... (4 Replies)
Discussion started by: raidzero
4 Replies

10. Shell Programming and Scripting

Reading lines within vi editor

Hi All, I need to read line by line from a file(created using vi editor) till end of the file and pass it to my own executables so that it will read first line and execute and then other and so on...Thanks The steps are like this; 1) read first line in file 2) execute the job with first line as... (2 Replies)
Discussion started by: asriva26
2 Replies
Login or Register to Ask a Question