VIM finding and commenting lines
Alright so I have a large text file with a certian phrase in the middle of the line that indicates that the entire line should be commented out (it is actually a fortran source file). I was trying to work out how to make substitution do this, but I am not sure because I would like to leave the rest of the line intact, any clues?
|
Alright well I came up with a sort of replacement for a direct substitution. VIM has a record command mode. So I started recording, did a find, did an insert, hit esc, then stopped recording. Then I just hit @q, @@, @@... until the end of the file.
|
You can do it with the substitute command:
%s/^.* mace .*$/REM &/ This will find all lines that contain the string ' mace ' and put the string 'REM ' at the beginning of each. |
I knew there had to be a variable for the matching string (&) thanks man. The comment out in fortran 77 (which I have the dubious honor of using) is btw.
|
All times are GMT -5. The time now is 02:14 AM. |