| 
     
       |  |  |  | 
            
              | 
             
               | 
               
                 |  | UGU: Unix Guru Universe - Unix Tip #4180- July 22, 2012
 -  Home : Help
 : Today's Tip Unix Tip #4180- July 22, 2012
 
 
COMMENT OUT MULTIPLE LINES 
Ever wanted to comment out
 multiple lines of code while
 writing shell
 scripts in vi, but didn't want
 to pound your keyboard for half
 an hour doing it?
 
 (I#Escape j.j.j.j. = carpal tunnel)
 
 Here's the nerdy way to do it:
 
 :.,+N-1 s/^/#/g
 
 Where N-1 is the number of lines
 minus one that you want to comment
 out, and s/^/#/g is the regular
 expression (the pattern between the
 first two slashes is what you want
 to replace, in this case the
 beginning of the line, and the
 pattern between the last two slashes
 is what you want to replace it with).
 
 For example, if you're a bad
 coder like me and want to comment
 out 500 lines of code, you would do:
 
 :.,+499 s/^/#/g
 
 
 
 This tip generously supported by: maddox@xmission.com
 
 NOTE: All tips provided are USE AT YOUR OWN RISK. Tips are submitted
by various unix admins around the globe. UGU suggest you read and
test each tip in a non-volitile environment before placing into
production.
 
 LAST 5 TIPS
 4179
 - HOW MUCH SOLARIS MEMORY?
 4178
 - EDITING OF LARGE FILES
 4177
 - LEAKING MEMORY?
 4176
 - TRUSS THE PID.....
 4175
 - VERIFY AFTER VACATIONS
 I want to 
 SUBSCRIBE
 and get a UGU Tip everyday.
 I want to 
 UNSUBSCRIBE
 and NOT get a UGU Tip everyday.
 If you have a UNIX TIP let us know, we just may use it:
(All tips become the property of the Unix Guru Universe)
 |  |  
                 |  |  
                 |   Copyright 1994-2024 Unix Guru Universe 
 |  |  |  |  |