Unix questions - About vim

This is Interesting: Free IT Magazines  
Home > Archive > Unix questions > February 2004 > About vim





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author About vim
Marmagya

2004-02-23, 6:33 pm

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

Maurizio Loreti

2004-02-23, 7:33 pm

Marmagya <marmagya@eNOpatra_SPAM.com> writes:

> 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?


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: ybergv@cq.vasa.vg
Peter Jensen

2004-02-23, 7:33 pm

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

Marmagya wrote:

> 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.


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

> 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


That would probably be '\r'.

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

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

iD8DBQFAOxS3d1ZThqotgfgRAm22AKCUgbBgIqcX
F3ZlR5US95D3qqIQCgCeKd21
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"
Jim Richardson

2004-02-23, 8:34 pm

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

On Tue, 24 Feb 2004 13:34:20 +0530,
Marmagya <marmagya@eNOpatra_SPAM.com> wrote:
> 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
>

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


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

iD8DBQFAOxpvd90bcYOAWPYRAnvuAJwP1VaGIPy6
M2XkeDZ+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?
Donn Miller

2004-02-23, 9:33 pm

Marmagya wrote:
> 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


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 webservertalk.com, Uncensored Usenet News =-----
http://www.webservertalk.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
The Onion Man

2004-02-24, 2:34 am

Marmagya sighed and said:

> 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


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.

cola_moderator

2004-02-24, 8:34 am

Donn Miller <dmmiller@cvzoom.net> wrote in message news:<403b251e$1_2@corp.newsgroups.com>...
> 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.


....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!
Rich Teer

2004-02-24, 9:34 am

On Tue, 24 Feb 2004, cola_moderator wrote:

> ...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!


___________________
/| /| | |
||__|| | 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
joe@invalid.address

2004-02-24, 9:34 am

Rich Teer <rich.teer@rite-group.com> writes:

[...]

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


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
Rich Teer

2004-02-24, 12:34 pm

On Tue, 24 Feb 2004 joe@invalid.address wrote:

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


Not at all - go right ahead!

> 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.


Indeed...

--
Rich Teer, SCNA, SCSA

President,
Rite Online Inc.

Voice: +1 (250) 979-1638
URL: http://www.rite-online.net
The Ghost In The Machine

2004-02-25, 12:34 pm

In comp.os.linux.advocacy, cola_moderator
<cola_moderator@hotmail.com>
wrote
on 24 Feb 2004 14:02:43 -0800
<d5d0727e.0402241402.5eb329e1@posting.google.com>:
> Donn Miller <dmmiller@cvzoom.net> wrote in message news:<403b251e$1_2@corp.newsgroups.com>...
>
> ...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!


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.co....klez.h@mm.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.co...etsky.b@mm.html

or MyDoom, a classic:

http://securityresponse.symantec.co....a@mm.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, ewill3@earthlink.net
It's still legal to go .sigless.
Jan van den Broek

2004-02-25, 4:34 pm

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

[Schnipp]

>...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!


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

--
Jan van den Broek
balglaas@xs4all.nl

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






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com