Professional Web Applications Themes

About vim - UNIX Programming

Hi, I have a text file which I am opening in vi/vim/gvim. I want to replace a particular character with a newline character. How can I do it? For ex, I have the file containing line: I am a good boy.^MI am regular at work. Now I want to replace this '^M' with a new line. In other words, what should I relplace '??' with in the following search and replace command: :%s/CtrlV+M/??/g Regards Marmagya...

  1. #1

    Default About vim

    Hi,
    I have a text file which I am opening in vi/vim/gvim. I want to
    replace a particular character with a newline character. How can I do it?
    For ex, I have the file containing line:

    I am a good boy.^MI am regular at work.

    Now I want to replace this '^M' with a new line. In other words, what
    should I relplace '??' with in the following search and replace command:

    :%s/CtrlV+M/??/g

    Regards
    Marmagya

    Marmagya Guest

  2. #2

    Default Re: About vim

    Marmagya <com> writes:
     

    Depends from what a newline character is on your platform. On mine is
    a ^J, on your I dunno.

    --
    Maurizio Loreti http://www.pd.infn.it/~loreti/mlo.html
    Dept. of Physics, Univ. of Padova, Italy ROT13: vasa.vg
    Maurizio Guest

  3. #3

    Default Re: About vim

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    Marmagya wrote:
     

    Would this by any chance be a DOS or MAC text file? In that case just
    use the conversion tools dos2unix or mac2unix.
     

    That would probably be '\r'.

    [Followup-To: comp.os.linux.advocacy]

    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.2.3 (GNU/Linux)

    iD8DBQFAOxS3d1ZThqotgfgRAm22AKCUgbBgIqcXF3ZlR5US95 D3qqIQCgCeKd21
    b1/sIgNpyO7594XGIzHsgGo=
    =WWmG
    -----END PGP SIGNATURE-----
    --
    PeKaJe

    Americans' greatest fear is that America will turn out to have been a
    phenomenon, not a civilization. -- Shirley Hazzard, "Transit of Venus"
    Peter Guest

  4. #4

    Default Re: About vim

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    On Tue, 24 Feb 2004 13:34:20 +0530,
    Marmagya <com> wrote: 
    :%s/CtrlV^M/\r/g


    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.2.4 (GNU/Linux)

    iD8DBQFAOxpvd90bcYOAWPYRAnvuAJwP1VaGIPy6M2XkeDZ+L/6vrqFULgCgttgq
    p+uh6mEg3ULCCwSYyTEoad8=
    =4qpm
    -----END PGP SIGNATURE-----

    --
    Jim Richardson http://www.eskimo.com/~warlock
    Why is the symbol for anarchy always written the same way?
    Jim Guest

  5. #5

    Default Re: About vim

    Marmagya wrote: 

    How about:

    sed 's/\r/\n/g' somefile > newfile

    Or,

    perl -pi -e 's/\r/\n/g' somefile

    I usually like to use a comma instead of a forward-slash as my
    delimeter, though it doesn't matter, as long as the same delimiter is
    used througout.


    -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
    http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
    -----== Over 100,000 Newsgroups - 19 Different Servers! =-----
    Donn Guest

  6. #6

    Default Re: About vim

    Marmagya sighed and said:
     

    There is the utility fromdos which according to its man page

    takes a DOS text file as stdin and sends a UNIX text file
    to stdout. DOS text file format separates lines of text by two
    characters: CR followed by LF (hex 0d 0a). UNIX text file format
    separates lines of text with a single LF character (hex 0a). This
    program changes the CR LF groups found in the input stream to LF
    in the output stream.

    I know this is outside of vim, but it might just work...

    --
    Ian

    I fought Windows from 95 to 2000.
    It beat me every time.
    That's why I use Linux.

    The Guest

  7. #7

    Default Re: About vim

    Donn Miller <net> wrote in message news:<403b251e$newsgroups.com>... 
    >
    > How about:
    >
    > sed 's/\r/\n/g' somefile > newfile
    >
    > Or,
    >
    > perl -pi -e 's/\r/\n/g' somefile
    >
    > I usually like to use a comma instead of a forward-slash as my
    > delimeter, though it doesn't matter, as long as the same delimiter is
    > used througout.[/ref]

    ....or you can forget about the past and fast forwared to the future
    .... dump all that retarded goofy old-fashined beta linux software and
    upgrade to one of the many top quality text editor available under
    windows xp professional ... forget about vi, vim, gvim and all that
    crap, that's only for morons!
    cola_moderator Guest

  8. #8

    Default Re: About vim

    On Tue, 24 Feb 2004, cola_moderator wrote:
     

    ___________________
    /| /| | |
    ||__|| | Please do |
    / O O\__ NOT |
    / \ feed the |
    / \ \ trolls |
    / _ \ \ ______________|
    / |\____\ \ ||
    / | | | |\____/ ||
    / \|_|_|/ \ __||
    / / \ |____| ||
    / | | /| | --|
    | | |// |____ --|
    * _ | |_|_|_| | \-/
    *-- _--\ _ \ // |
    / _ \\ _ // | /
    * / \_ /- | - | |
    * ___ c_c_c_C/ \C_c_c_c____________

    --
    Rich Teer, SCNA, SCSA

    President,
    Rite Online Inc.

    Voice: +1 (250) 979-1638
    URL: http://www.rite-online.net
    Rich Guest

  9. #9

    Default Re: About vim

    Rich Teer <com> writes:

    [...]
     

    Good one. Mind if I steal it for future use?

    I know a couple trolls who will complain about it as a waste of
    bandwidth. Funny how trolls always accuse others of what they do.

    Joe
    --
    "I didn't really say everything I said."
    - Yogi Berra
    joe@invalid.address Guest

  10. #10

    Default Re: About vim

    On Tue, 24 Feb 2004 address wrote:
     

    Not at all - go right ahead!
     

    Indeed...

    --
    Rich Teer, SCNA, SCSA

    President,
    Rite Online Inc.

    Voice: +1 (250) 979-1638
    URL: http://www.rite-online.net
    Rich Guest

  11. #11

    Default Re: About vim

    In comp.os.linux.advocacy, cola_moderator
    <com>
    wrote
    on 24 Feb 2004 14:02:43 -0800
    <google.com>: 
    >>
    >> How about:
    >>
    >> sed 's/\r/\n/g' somefile > newfile
    >>
    >> Or,
    >>
    >> perl -pi -e 's/\r/\n/g' somefile
    >>
    >> I usually like to use a comma instead of a forward-slash as my
    >> delimeter, though it doesn't matter, as long as the same delimiter is
    >> used througout.[/ref]
    >
    > ...or you can forget about the past and fast forwared to the future
    > ... dump all that retarded goofy old-fashined beta linux software and
    > upgrade to one of the many top quality text editor available under
    > windows xp professional ... forget about vi, vim, gvim and all that
    > crap, that's only for morons![/ref]

    Yes, there are many fine editors out for Windows.

    Klez, for example, does a very nice job of modifying the registry,
    among other things.

    Features:
    * Automatic registry editing.
    * Disabling of virus scanners for performance improvements.
    * Automatic copying to other drives and network drives.
    * Automatic emailing to other users, for rapid transmission of updates.
    * Free bonus program: Elkern.4926

    Order now:

    http://securityresponse.symantec.com/avcenter/venc/data/html

    If you need only a Category 2 Program, you can get the Nimda editor.
    This variant requires, however, that one install IIS first, and
    the computer needs to be rebooted for full installation of the editor.

    For a bleeding-edge Category 4 editor, there's the Netsky editor:

    http://securityresponse.symantec.com/avcenter/venc/data/html

    or MyDoom, a classic:

    http://securityresponse.symantec.com/avcenter/venc/data/html?Open

    Oh...wait...you meant a *text* editor.

    Never mind.

    :-)

    ObUnix: These programs are Windows-specific. The only
    worry Unix admins would have regarding these
    programs is the protecting against inadvertant
    relay of what might be construed polluted waste
    messages to unprotected subnets.

    --
    #191, net
    It's still legal to go .sigless.
    The Guest

  12. #12

    Default Re: About vim

    24 Feb 2004 14:02:43 -0800
    com (cola_moderator) schrieb:

    [Schnipp]
     

    You're talking about Edlin, aren't you?
    (Or maybe that new-fangled "qbasic /editor" stuff)

    --
    Jan van den Broek
    nl

    I've got a /dev/null, and I'm not afraid to use it.
    Jan Guest

  13. #13

    Default Re: About vim

    On 2004-02-24, The Onion Man wrote: [/ref]

    :%s/CtrlV+M/\r/g
     

    fromdos? (and todos to go the other way)
     

    :set ff=unix (or :set ff=dos to go the other way) does the same from
    within vim although it will only work if you just have one type of
    linebreak in the file.

    --
    Mike Peters
    mike [-AT-] ice2o [-DOT-] com
    http://www.ice2o.com
    Mike Guest

  14. #14

    Default Re: About vim

    On 2004-02-29, Mike Peters wrote: [/ref]
    Sorry I read that sentence wrong, I read fromdos as umsdos hence: 

    --
    Mike Peters
    mike [-AT-] ice2o [-DOT-] com
    http://www.ice2o.com
    Mike Guest

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139