Search and replace in vi editor - Unix

This is a discussion on Search and replace in vi editor - Unix ; Hi, Can you please no the regular expression to use for" Search and replace the 2 or more spaces(blank characters) in between word with , or . or TAB OR I want replace , (comma) character with 2 or more ...

+ Reply to Thread
Results 1 to 5 of 5

Thread: Search and replace in vi editor

  1. Search and replace in vi editor

    Hi,

    Can you please no the regular expression to use for"

    Search and replace the 2 or more spaces(blank characters) in between
    word with , or . or TAB

    OR

    I want replace , (comma) character with 2 or more space characters in
    between words of a file (globally) by using vi editor

  2. Re: Search and replace in vi editor


    Edu.Resources;2604426 Wrote:
    >
    >
    > I want replace , (comma) character with 2 or more space characters in
    > between words of a file (globally) by using vi editor


    For the above, i think you can achieve using below command in "visual"
    mode. This will replace all "commas" in the viewed file.

    :.,$s/,/\ \ /

    Further reading 'Vi Pages - Substitution Guide'
    (http://www.guckes.net/vi/substitute.html)


    --
    mrrijo
    ------------------------------------------------------------------------
    mrrijo's Profile: http://fantasticunix.com/forum/member.php?userid=21
    View this thread: http://fantasticunix.com/forum/showthread.php?t=508454


  3. Re: Search and replace in vi editor

    In <30b8fc68-201f-4673-aa01-a0f1cafee40e@p31g2000prf.googlegroups.com> "Edu.Resources" writes:

    > I want replace , (comma) character with 2 or more space characters in
    > between words of a file (globally) by using vi editor


    Your wording is ambiguous. Do you want to replace a comma with two spaces?
    Or do you want to replace a comma and two or more spaces with something
    else?

    --
    John Gordon A is for Amy, who fell down the stairs
    gordon@panix.com B is for Basil, assaulted by bears
    -- Edward Gorey, "The Gashlycrumb Tinies"


  4. Re: Search and replace in vi editor

    On Aug 6, 8:49*pm, John Gordon wrote:
    > In <30b8fc68-201f-4673-aa01-a0f1cafee...@p31g2000prf.googlegroups.com> "Edu.Resources" writes:
    >
    > > I want replace , (comma) character with 2 or more space characters in
    > > between words of a file (globally) by using vi editor

    >
    > Your wording is ambiguous. *Do you want to replace a comma with two spaces?
    > Or do you want to replace a comma and two or more spaces with something
    > else?
    >
    > --
    > John Gordon * * * * * * * * * A is for Amy, who fell down the stairs
    > gor...@panix.com * * * * * * *B is for Basil, assaulted by bears
    > * * * * * * * * * * * * * * * * -- EdwardGorey, "The Gashlycrumb Tinies"



    Yes John,

    I want replace leading spaces( ie 2 or more spaces) with comma

    let's give the Example: hello world there is lot wired
    problems <---- problem

    hello(2)world(1)there(5)is(1)lot(3)wired(1)problem s <---------
    explanation is- number incates that number spaces in between words so
    i want here replace 2 and more spaces in between word with comma(,)

    results: hello,world(1)there,is(1)lot,wired(1)problems

    I hope you understand the problem.

  5. Re: Search and replace in vi editor

    In <24ace8f5-446a-471d-9f66-324cc5a26693@p10g2000prf.googlegroups.com> "Edu.Resources" writes:

    > I want replace leading spaces( ie 2 or more spaces) with comma


    :1,$s/ */,/

    --
    John Gordon A is for Amy, who fell down the stairs
    gordon@panix.com B is for Basil, assaulted by bears
    -- Edward Gorey, "The Gashlycrumb Tinies"


+ Reply to Thread