Vim removes line endings when a file is read, so there may not
be any CR in the buffer that is displayed. Search for \n to find
what Vim has detected as a line ending.
To convert from one line ending type to another, see:
For testing, you can enter insert mode and type Ctrl-V Enter (or
Ctrl-Q Enter if you have mapped Ctrl-V to paste). That will
insert a CR displayed as ^M (Ctrl-M = 13 = CR). Searching for \r
will find it.
what does your fileformat say when you are in vim? (:set fileformat)
What OS are you using?
Are you specifically looking for carriage returns? If you are just
looking for end-of-lines, then the following will serve you better:
Otherwise, see John Beckitt's sibling post.
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
> I've only been using Vim for a week now, but with every passing day
> am more and more impressed by its power.
And it is only the first week :D Boy, you have no idea how good this
will still get!! The real fun starts after you've assimilated the vim
mindset. That usually requires about a month imho. Then the true power
starts to show itself. I suggest grabbing a good cheat sheet off the
net for some ideas once things start to become fluent. Also check out
some of the .vimrc files used by seasoned vimmers. That should provide
some input for getting some of the more obscure, but very useful
And once things are up to speed, try
By the way, you would have gotten immediate answers if you had asked
that to begin with. As a matter of fact it is a FAQ (12.4 on
You almost always get inferior answers if you presume what the solution
is instead of stating the problem you want to solve. It never hurts to
say what solution you *tried* but stating the problem let's the more
imaginative members of the list really shine. :-)
My two cents,
On Di, 24 Mai 2011, Jean-Rene David wrote:
> * JP Lew [2011.05.24 04:20]:
> > My original problem was that I wanted to delete all the blank lines in my
> > document.
> By the way, you would have gotten immediate answers if you had asked
> that to begin with. As a matter of fact it is a FAQ (12.4 on
By the way, that page is outdated. The current version is available at
Gl�ckliche M�dgen in der Ehe lieben schon Romane nicht mehr, weil sie
nichts mehr auf sich beziehen k�nnen.
-- Jean Paul
It may be vi-compatible, but it's one of those "Vim quirks" which one
has to know: in Vim, to replace a line break by itself, you use :s/\n/\r
-- i.e., search for \n to find a line break, insert \r to add a line break.
Don't ask me why.
There once was a member of Mensa
Who was a most excellent fencer.
The sword that he used
Was his -- (line is refused,
And has now been removed by the censor).
> On 24/05/11 14:31, Eljay Love-Jensen wrote:
>> I'm not sure why I have to search FOR multiple \n and replace WITH the
>> \r. That may be a vi-thing, a Vim-thing, or a quirk / detail of my
>> platform (Windows 7, using the prebuilt gVim, using :set ff=unix line
>> endings). Hmmm, I never thought about that discrepancy before. [...]
> It may be vi-compatible, but it's one of those "Vim quirks" which one has to know: in Vim, to replace a line break by itself, you use :s/\n/\r -- i.e., search for \n to find a line break, insert \r to add a line break.
And all these years, I've been using
Where "^M" is typed "control-v, control-m") Usin
> Don't ask me why.
I can't tell you why "\n" matches newline on the "search" side of the substitute command, but inserts <00> ("null", equivalent to ^@) on the replace side. It is a mystery of life.
Obviously, "\r" means "return", short for "carriage return" but "\n" seems to mean both "newline" and "null" to vim.
PS: While reading up on this, I discovered something new, at least to me:
Save typing by using \zs and \ze to set the start and end of a pattern.
For example, instead of:
:s/Copyright 2007 All Rights Reserved/Copyright 2008 All Rights Reserved/
:s/Copyright \zs2007\ze All Rights Reserved/2008/
How cool is that?
Quite cool, and of course, in this particular case you could even do
:s/Copyright 200\zs7\ze All Rights Reserved/8/
A programming language. Related to certain social diseases in
that those who have it will not admit it in polite company.