On Thu, Jul 15, 2004 at 07:45:26PM +0200, Matthias Czapla wrote: > On Thu, Jul 15, 2004 at 11:05:32AM -0400, David Turetsky wrote: > > > i have a file like; > > > > > > # > > > one > > > 123 > > > > > > and i would like to APPEND a # at the beginning of > > > each line 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. > > :1,$s/^\([^#].*\)/#\1/ > > should do it in vi.
Nope. Doesn't meet the spec. He wanted *every* line that did not start with '#', which would include blank lines. Your solution omits blank lines. Of course he might have mis-stated the specs. -- "When I am working on a problem I never think about beauty. I only think about how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -- R. Buckminster Fuller Rick Pasotto [EMAIL PROTECTED] http://www.niof.net -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]