Skip to content
Tags

, ,

Replacing a new line with new line

April 1, 2011

So, I recently wanted to replace add at the end of each line (for about 2000 lines) a “, . The vim control block was just not working to solve this problem.

What I ended up doing is trying to find a new line and then replace it with a : “, <newline>

Now, the way you would have thought the command to this would be is

:%s/\n/",\n/gc

but the weird thing is while the ‘find’ part of that string works fine, the replace part does not.

So the the real command should be

:%s/\n/",^M/gc

The ^M corresponds to the newline.

Note: ^M is not entered by actually typing those characters but by hitting the keys ‘cntrl V Enter’.

Here is the link: http://code.google.com/p/macvim/issues/detail?id=194

Advertisements

From → Uncategorized

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: