[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: vi globally append question



On Thu, Jul 15, 2004 at 06:49:20AM -0700, Sean wrote:
> hi all,
> 
> i have a file like;
> 
> # one 123
> 
> and i would like to APPEND a # at the beginning of each line

'append' means to add to the end. It is impossible to append to the
beginning of something.

> which is not started with a # . how can i do it with vi or ed, so far,
> i 've tried;
> 
> :%s/^[a-z]:[0-9]/#/g
> 
> but this would CHANGE the first character of each line to a hash, pls
> help.

:%g/^[^#]/s/^/#/

Translation:

%       for every line in the file
g       process those that match the following RE
/^[^#]/ the line starts with something other than '#'
s       substitute
/^/     the beginning of the line
#/      with a '#'

-- 
"Today I am more than ever frightened. I wish it would dawn upon engineers 
 that, in order to be an engineer, it is not enough to be an engineer."
	-- Jose Ortega y Gasset
    Rick Pasotto    rick@niof.net    http://www.niof.net



Reply to: