LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-23-2004, 08:45 PM   #1
k4zau
Member
 
Registered: Feb 2003
Location: huntsville, al
Distribution: debian, opensolaris
Posts: 99

Rep: Reputation: 15
Wink Text Reflow in Vim


On older versions of Micro$oft Works there was a useful function called "Reflow" that removed unnecessary line breaks and tabs from a paragraph. It was needed because word-wrapping was still in its infancy at the time and after multiple edits, a paragraph would have some lines that were really short, others really long, and unneeded line breaks.


e.g. it would turn a paragraph
like this into
a nice paragraph like the
one
above.


What I want to be able to do is make Vim fix this for me. I import a lot of DOS-format text files into Vim, and I have a large collection of files that were created in GUI text editors. Both look terrible when I view them with Vim because they have all kinds of line breaks and such.

Anyone know how to do this?
 
Old 02-23-2004, 09:32 PM   #2
lyle_s
Member
 
Registered: Jul 2003
Distribution: Slackware
Posts: 392

Rep: Reputation: 55
I'm not sure how you'd do this in vim, but the "fmt" command should work for you.

Lyle
 
Old 02-28-2004, 07:41 PM   #3
k4zau
Member
 
Registered: Feb 2003
Location: huntsville, al
Distribution: debian, opensolaris
Posts: 99

Original Poster
Rep: Reputation: 15
Thanks for the tip. This command will work for what I need, although I still wish it were in Vim.
 
Old 02-28-2004, 08:08 PM   #4
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
Position the cursor at the beginning of the paragraph and type

gqap

To remove returns, something like

:g/^M/s///g

might do. (The ^M is actually created by typing 'ctrl-V' and then hitting return.)

The builtin vim help and Google are great. I'm still figuring vim out and probably always will be.
 
Old 02-29-2004, 10:32 AM   #5
k4zau
Member
 
Registered: Feb 2003
Location: huntsville, al
Distribution: debian, opensolaris
Posts: 99

Original Poster
Rep: Reputation: 15
wow.... thanks!
that works like a charm.
i think i'll have to associate that to a key combo for quick access.
 
  


Reply



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
How change text color using linux in text mode only runlevel 3? Xavius Linux - General 7 05-07-2009 02:19 AM
encryption with Vim (vim -x) mikshaw Linux - Software 2 03-07-2007 09:00 AM
Which light text editor can copy text from file and paste in browser? davidas Linux - Software 9 03-06-2006 11:28 AM
How to find and change a specific text in a text file by using shell script Bassam Programming 1 07-18-2005 07:15 PM
copying blocks of text using vim p0rt Linux - Software 2 09-23-2004 03:05 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:28 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
Open Source Consulting | Domain Registration