Remove carriage return

0 views
Skip to first unread message

Vim Questions

unread,
Dec 18, 2008, 10:32:56 AM12/18/08
to vim...@googlegroups.com
Thank you, John, for your responce
 
It did not work for me.
 
I installed gVim 7.2 on my lap top (Windows). When I double click on it, it opnes. I go to "file-> open" and bring my text  (that is in .txt format). I enterred the recommended command (copy and paste from your e-mail) in the first line that is before the text.
Nothing happened.
 
Is anything that I did wrong?

Tgank you for your help,
Tom
On Tue, Dec 16, 2008 at 8:11 PM, John Beckett <johnb....@gmail.com> wrote:

Vim Questions wrote:
> I need to remove carriage return (Char 13) from a text.
> Was adviced to use Vim. (MS-Windows).

In normal mode (after pressing Escape), enter command:

:%s/\r//g

That will remove all CR characters. See:
http://vim.wikia.com/wiki/Change_end-of-line_format_for_dos-mac-unix

For the future, please:

- Use a suitable subject ("Remove carriage return").
 If you can't think of a subject, don't send a question.

- Consider using a suitable name.
 Why would anyone want to reply to "Vim Questions"?

John


Matt Wozniski

unread,
Dec 18, 2008, 12:32:16 PM12/18/08
to vim...@googlegroups.com
On Thu, Dec 18, 2008 at 10:32 AM, Vim Questions wrote:
> Thank you, John, for your responce
>
> It did not work for me.
>
> I installed gVim 7.2 on my lap top (Windows). When I double click on it, it
> opnes. I go to "file-> open" and bring my text (that is in .txt format). I
> enterred the recommended command (copy and paste from your e-mail) in the
> first line that is before the text.
> Nothing happened.

Does

:set ff?

print out 'dos' or 'mac'? If so, you can convert the file to unix
line endings by doing these two commands:

:set ff=unix
:w

~Matt

fritzophrenic

unread,
Dec 18, 2008, 1:50:14 PM12/18/08
to vim_use


On Dec 18, 9:32 am, "Vim Questions" <vimquestion...@gmail.com> wrote:
> Thank you, John, for your responce
>
> It did not work for me.
>
> I installed gVim 7.2 on my lap top (Windows). When I double click on it, it
> opnes. I go to "file-> open" and bring my text  (that is in .txt format). I
> enterred the recommended command (copy and paste from your e-mail) in the
> first line that is before the text.
> Nothing happened.
>
> Is anything that I did wrong?
>

For your immediate problem, don't copy and paste into the text.

Instead, type exactly the following character sequence:

:%s/\r//g

Then, press the ENTER key.

(this assumes you have launched Vim in its default mode...NOT the "vim
easy mode" that also comes with Windows installers I've seen)

I cannot stress enough that you should learn to use Vim in general
terms by using the tutorial that ships with Vim. You can access this
tutorial through the start menu if you used a standard Vim installer.
If you can't find it there, it should also be accessible by running
the vimtutor.bat file in your installation directory (probably C:
\Program Files\vim\vim72\vimtutor.bat)

From the vimtutor, you will learn what you just did:

: -> enters "command mode"
% -> runs the following command on every line in the file
s -> run the "s" a.k.a. "substitute" command
/\r -> in the substitute command, search for a carriage return
// -> replace it with nothing
g -> for every occurrence in the line
ENTER -> run the command and exit command mode

Vim Questions

unread,
Dec 23, 2008, 3:36:33 PM12/23/08
to vim...@googlegroups.com
Thank you, Matt
 
I appritiate it
 
Have a nice day

Reply all
Reply to author
Forward
0 new messages