LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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-20-2008, 03:05 PM   #1
jantman
Member
 
Registered: Nov 2005
Location: New Jersey, USA
Distribution: SuSE
Posts: 492

Rep: Reputation: 31
Emacs - convert whitespace to single space?


Hi,

I'm looking for a little elisp (EMACS) function that will convert whitespace (preferably also line breaks) from the point until the next text character into one space.

I'm dealing with a query log file that looks like:
Code:
SELECT
                        usr_lang
                    FROM
                        eventum.eventum_user
                    WHERE
                        usr_id = 2
Since this is all one query, I'd like it all on one line. I'm also editing out the stuff I don't need on-the-fly, and adding punctuation and notes, so it doesn't seem like the best job for a script (since there aren't any semicolons, I need to find the end of the query manually).

Ideally, I'd like to just map the function to an F key, to get something like:

Code:
SELECT{}
                        usr_lang
With the point being at "{}", Press F-whatever and get:
Code:
SELECT usr_lang
Any ideas?

Thanks,
Jason
 
Old 02-20-2008, 09:03 PM   #2
BrianK
Senior Member
 
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Rep: Reputation: 51
you may try something like regex replace, i.e.

M-cntl-% (that's alt-cntl-shift-5)
the for the query, use:
[ cntl-q-j]* (that's bracket, space, cntl-q-j,bracket,star)
and for the reaplce, use a single space.

.. works moderatly well.

Last edited by BrianK; 02-20-2008 at 09:15 PM.
 
  


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
Convert a index.htm into single clear list of http:// links frenchn00b Programming 6 10-30-2007 05:48 AM
convert 2 cd avi to a single dvd initDr Linux - Software 1 08-10-2006 03:57 AM
emacs - convert auto indent tabs to spaces? BrianK Linux - General 1 04-15-2004 11:14 PM
Deleting single space characters from a file NeoDaNeenjah Linux - Newbie 2 03-16-2004 03:27 AM
Application to place single space with % between each line MasterC Linux - General 2 05-18-2003 02:16 PM

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

All times are GMT -5. The time now is 03:24 PM.

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