LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-26-2009, 08:41 PM   #1
ColInvictus
Member
 
Registered: Apr 2009
Posts: 42

Rep: Reputation: 15
vim remove line breaks


I've copied a bunch of text into vim and I need to get rid of the line breaks. I've tried
:%s/^M// (where ^M is C-v C-m)
and
:%s/.$//
and
:%s/\x0D$//
and
:%s/\$//

none of which work. If I issue
:set invlist

all lines are terminated with a '$'. How can I get rid of them?

Ta
Col
 
Old 09-26-2009, 09:21 PM   #2
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
s/\n//

or the 'j' command on particular lines
 
Old 09-27-2009, 06:16 AM   #3
ColInvictus
Member
 
Registered: Apr 2009
Posts: 42

Original Poster
Rep: Reputation: 15
's/\n//'! I always miss the obvious ones... Thanks slakmagik
 
Old 09-27-2009, 09:10 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
Or run dos2unix <file> at the cmd line.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
vi not obeying line breaks OR relabel partitions davidstvz Linux - Newbie 3 01-02-2009 01:43 PM
Mutt mysteriously changes/breaks vim settings HypoCee Linux - Desktop 1 12-19-2006 10:21 AM
Line breaks aren't interpreted when defining a variable spiffytech Linux - Software 4 12-27-2005 04:08 PM
Need REG EXP Help to remove line breaks webshark Programming 18 07-08-2005 05:31 PM
Line breaks in html with perl script BroX Programming 18 01-10-2005 10:07 AM


All times are GMT -5. The time now is 03:18 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration