How to replace a character for a newline in Vim?

– Vinko Vrsalovic Sep 16 '08 at 11:22 1 No idea. ;-) It just does and I never bothered to investigate. Shame on me.

:-/ – Konrad Rudolph Sep 16 '08 at 11:26 20 /r is treated as pressing the Enter/Return key. It works on all platforms. – Luka Marinko Oct 12 '08 at 11:41 for whatever reason, replacing all '\n with ',\n works when doing: %s/'\n/',\r/g – tipu Oct 27 at 20:20.

Here's the trick: First, set your vi(m) session to allow pattern matching with special characters (ie: newline). It's probably worth putting this line in your . Vimrc or .

Exrc file. :set magic Next, do: :s/,/,^M/g To get the ^M character, type ctrl-v and hit enter. Under Windows, do ctrl-q enter.

The only way I can remember these is by remembering how little sense they make: "What would be the worst control-character to use to represent a newline? " "Either 'q' ( because it usually means "Quit") or 'v' because it would be so easy to type ctrl-c by mistake and kill the editor. " "Make it so.

17 Whenever I hear the word "magic" in a programming context, I get scared. – David Rivers Jan 11 at 15:56 I'm using GVim on Windows, and I need neither the :set magic (it's not in my ~/_vimrc either) or ctrl-q. Just a simple ctrl-v followed by enter creates the ^M character for me just fine.

– Chris Phillips Sep 14 at 21:02 Awesome, works great! :) – MasterZ Sep 27 at 12:13.

With Vim on Windows use Ctrl+Q in place of Ctrl+V.

Thanks! I've been looking for that little tidbit. – Darcy Casselman Mar 2 '09 at 18:51.

You need to use :%s/,/^M/g To get the ^M character, press Ctrl+V followed by ENTER.

From eclipse, the ^M's can be embedded in a line, and you want to convert them to newlines. :s/\r/\r/g Makes no sense, but it works.

Ctrl-V pastes the contents of Windows system buffer.

Here's the trick: First, set your vi(m) session to allow pattern matching with special characters (ie: newline). It's probably worth putting this line in your . Vimrc or .

Exrc file.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions