Ask a Question related to Linux / Unix Administration, Design and Development.
-
yls177 #1
vi, adding words to the beginning of each line
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
yls177 Guest
-
Getting line breaks between words
Is there a way to have InDesign wrap to a new line between words? Here's why ... I'm working on a VDP (Variable Data Printing) project of an eye... -
What does a semicolon do at the beginning of a line?
Was browsing the documentation on reading a configuration file and found this. What does a semicolon do at the beginning of a line? ; <?php DO... -
Add text to beginning every line
Hi Hope someone can help with this. I used to be able to do it, but now have forgotten. I want to prepend some text to every line in a file. The... -
replace words with bold words
Hello I was wondering if you guys could help me solve this using reg exp, i have a searchpage and a variable keywords that holds a number of... -
Write line at beginning of file?
Eric Pement <pemente@northpark.edu> wrote: What version of perl are you referring to? -
Mike #2
Re: vi, adding words to the beginning of each line
In article <c06e4d68.0404272137.a533b8f@posting.google.com> , yls177 wrote:
Are you wanting to add the word 'more' to the beginning of each line?> 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
:%s/^/more/
Mike Guest
-
Doug Freyburger #3
Re: vi, adding words to the beginning of each line
Mike wrote:
Dollars to donuts a space after that "more" will be a great idea ;^)>
> Are you wanting to add the word 'more' to the beginning of each line?
> :%s/^/more/
Doug Freyburger Guest
-
yls177 #4
Re: vi, adding words to the beginning of each line
Mike <mikee@mikee.ath.cx> wrote in message news:<108v6dcnrqo6of1@corp.supernews.com>...
i dont mind doing that.. so this ^ is the trick to direct vi that for> 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/
the beginning of each line, i want to add the word more?
yls177 Guest
-
Mark Rafn #5
Re: vi, adding words to the beginning of each line
>Mike <mikee@mikee.ath.cx> wrote in message
yls177 <yls177@hotmail.com> wrote:>> :%s/^/more/Not completely. %s is the replace operator, and the two things it needs are>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?
what to find and what to replace it with. ^ is the regular expression anchor
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 [email]dagon@dagon.net[/email] <http://www.dagon.net/>
Mark Rafn Guest
-
Tim Slattery #6
Re: vi, adding words to the beginning of each line
[email]yls177@hotmail.com[/email] (yls177) wrote:
The "s" says that you're typing a "substitute" command. The next>Mike <mikee@mikee.ath.cx> wrote in message news:<108v6dcnrqo6of1@corp.supernews.com>...>>> 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/
>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?
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
[email]Slattery_T@bls.gov[/email]
Tim Slattery Guest
-
Doug Freyburger #7
Re: vi, adding words to the beginning of each line
yls177 wrote:
It isn't a vi trick. It has nothing specifically to do with vi.> Mike wrote:
>>> > :%s/^/more/
> so this ^ is the trick to direct vi that for
> the beginning of each line
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.
Doug Freyburger Guest
-
yls177 #8
Re: vi, adding words to the beginning of each line
[email]dfreybur@yahoo.com[/email] (Doug Freyburger) wrote in message news:<7960d3ee.0405030902.f63d70e@posting.google.c om>...
> yls177 wrote:>> > Mike wrote:
> >> >> > > :%s/^/more/
> > 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.
how about addign something to the end of every line? surely its not
going to V the opposite of ^ :P
yls177 Guest
-
Bill Marcum #9
Re: vi, adding words to the beginning of each line
On 7 May 2004 03:14:08 -0700, yls177
<yls177@hotmail.com> wrote:No, $ represents the end of the line.> [email]dfreybur@yahoo.com[/email] (Doug Freyburger) wrote in message news:<7960d3ee.0405030902.f63d70e@posting.google.c om>...>>> yls177 wrote:>>>> > Mike wrote:
>> >
>> > > :%s/^/more/
>> >
>> > 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.
>
>
> how about addign something to the end of every line? surely its not
> going to V the opposite of ^ :P
--
Giraffe: a ruminant with a view.
Bill Marcum Guest
-
Doug Freyburger #10
Re: vi, adding words to the beginning of each line
yls177 wrote:
Regular expression character that means EOL is "$". man regexp> Doug Freyburger wrote>>> > yls177 wrote:> > > Mike wrote:>> > > > :%s/^/more/>> > > 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.
> how about addign something to the end of every line? surely its not
> going to V the opposite of ^ :P
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.
Doug Freyburger Guest
-
yls177 #11
Re: vi, adding words to the beginning of each line
[email]dfreybur@yahoo.com[/email] (Doug Freyburger) wrote in message news:<7960d3ee.0405070932.5e237629@posting.google. com>...
> yls177 wrote:>> > Doug Freyburger wrote>> > > yls177 wrote:
> > > > Mike wrote:>> > > > > :%s/^/more/>> > > > 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.
> > 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.
thanks for the advise.. will definitely get my hands on man regexp...
once i got my hands on the terminal...
yls177 Guest
-
David Douthitt #12
Re: vi, adding words to the beginning of each line
Doug Freyburger wrote:
A good recommendation - except for one thing. Remember that> 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.
file-globbing ("filename wildcards") are not the same as the usual
regular expressions.
A fairly obvious example: to the shell, a*.txt means all files that
begin with a, but to vi, grep, and others, it means any string that
begins with zero or more a's and ends in any character followed by a
"txt" string.
Also note that the more advanced features are different between things
such as sed, vi, grep, and egrep.
I recommend the UNIX in a Nutshell book - it covers all of these in a
concise manner in a chapter, and shows a list of all of the features
side by side for all places where they are used.
David Douthitt Guest



Reply With Quote

