vi, adding words to the beginning of each line
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix administration > vi, adding words to the beginning of each line




Pages (2): [1] 2 »   Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    vi, adding words to the beginning of each line  
yls177


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-28-04 06:34 AM

in vi-ing a file, i have a list of lines and they have different
alphabets when they begin a new line. now i wanted to add this "more"
to the beginning of each of these line. how can i do that?

basically, i am thinking of searching for the "next line" symbol.

thanks





[ Post a follow-up to this message ]



    Re: vi, adding words to the beginning of each line  
Mike


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-28-04 01:35 PM

In article <c06e4d68.0404272137.a533b8f@posting.google.com>, yls177 wrote:
> in vi-ing a file, i have a list of lines and they have different
> alphabets when they begin a new line. now i wanted to add this "more"
> to the beginning of each of these line. how can i do that?
>
> basically, i am thinking of searching for the "next line" symbol.
>
> thanks

Are you wanting to add the word 'more' to the beginning of each line?

:%s/^/more/





[ Post a follow-up to this message ]



    Re: vi, adding words to the beginning of each line  
Doug Freyburger


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-28-04 07:34 PM

Mike wrote:
>
> Are you wanting to add the word 'more' to the beginning of each line?
> :%s/^/more/

Dollars to donuts a space after that "more" will be a great idea ;^)





[ Post a follow-up to this message ]



    Re: vi, adding words to the beginning of each line  
yls177


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-30-04 04:35 PM

Mike <mikee@mikee.ath.cx> wrote in message news:<108v6dcnrqo6of1@corp.supernews.com>...[vbco
l=seagreen]
> In article <c06e4d68.0404272137.a533b8f@posting.google.com>, yls177 wrote:
 
>
> Are you wanting to add the word 'more' to the beginning of each line?
>
> :%s/^/more/[/vbcol]

i dont mind doing that.. so this ^ is the trick to direct vi that for
the beginning of each line, i want to add the word more?





[ Post a follow-up to this message ]



    Re: vi, adding words to the beginning of each line  
Mark Rafn


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-30-04 06:35 PM

>Mike <mikee@mikee.ath.cx> wrote in message 

yls177 <yls177@hotmail.com> wrote:[vbcol=seagreen]
>i dont mind doing that.. so this ^ is the trick to direct vi that for
>the beginning of each line, i want to add the word more?

Not completely.  %s is the replace operator, and the two things it needs are
what to find and what to replace it with.  ^ is the regular expression ancho
r
for beginning-of-line.  So this is matching 0 characters at the start of a
line, and replacing the match with the word "more".
--
Mark Rafn    dagon@dagon.net    <http://www.dagon.net/>





[ Post a follow-up to this message ]



    Re: vi, adding words to the beginning of each line  
Tim Slattery


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
04-30-04 06:35 PM

yls177@hotmail.com (yls177) wrote:

>Mike <mikee@mikee.ath.cx> wrote in message news:<108v6dcnrqo6of1@corp.super
news.com>... 
>
>i dont mind doing that.. so this ^ is the trick to direct vi that for
>the beginning of each line, i want to add the word more?

The "s" says that you're typing a "substitute" command. The next
character (the slash) is a delimiter. The caret (^) is a regular
expression character that matches the beginning of a line, telling the
substitute command that you want to insert some there (actually
replace the beginning of each line with something, which works out to
inserting something at the beginning of each line). The last bit,
"more", is what gets inserted.

--
Tim Slattery
Slattery_T@bls.gov





[ Post a follow-up to this message ]



    Re: vi, adding words to the beginning of each line  
Doug Freyburger


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
05-03-04 06:39 PM

yls177 wrote:
> Mike wrote:
> 
>
> so this ^ is the trick to direct vi that for
> the beginning of each line

It isn't a vi trick.  It has nothing specifically to do with vi.

The caret is the regular expression symbol for the start of a
line.  ANY program that uses regular expressions will use the
caret for the start of a line.  While there are several RE
libraries available, they all use the caret.





[ Post a follow-up to this message ]



    Re: vi, adding words to the beginning of each line  
yls177


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
05-07-04 11:34 AM

dfreybur@yahoo.com (Doug Freyburger) wrote in message news:<7960d3ee.0405030902.f63d70e@post
ing.google.com>...
> yls177 wrote: 
>
> It isn't a vi trick.  It has nothing specifically to do with vi.
>
> The caret is the regular expression symbol for the start of a
> line.  ANY program that uses regular expressions will use the
> caret for the start of a line.  While there are several RE
> libraries available, they all use the caret.



how about addign something to the end of every line? surely its not
going to V the opposite of ^ :P





[ Post a follow-up to this message ]



    Re: vi, adding words to the beginning of each line  
Bill Marcum


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
05-07-04 04:01 PM

On 7 May 2004 03:14:08 -0700, yls177
<yls177@hotmail.com> wrote:
> dfreybur@yahoo.com (Doug Freyburger) wrote in message news:<7960d3ee.04050
30902.f63d70e@posting.google.com>... 
>
>
>
> how about addign something to the end of every line? surely its not
> going to V the opposite of ^ :P
No, $ represents the end of the line.


--
Giraffe: a ruminant with a view.





[ Post a follow-up to this message ]



    Re: vi, adding words to the beginning of each line  
Doug Freyburger


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
05-08-04 03:40 PM

yls177 wrote:
> Doug Freyburger wrote> 
> 
> 
> 
> 
>
> how about addign something to the end of every line? surely its not
> going to V the opposite of ^ :P

Regular expression character that means EOL is "$".  man regexp
should be the starting point.  Learning regular expressions is
very important for SAs because they are used in everything from
filename wildcards through dozens of utilities.  Learn them in
the general case, be able to apply them everywhere.





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 10:13 AM.      Post New Thread    Post A Reply      
Pages (2): [1] 2 »   Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register