LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices


Reply
  Search this Thread
Old 01-12-2007, 11:01 AM   #1
Soabirw
LQ Newbie
 
Registered: Aug 2004
Posts: 10

Rep: Reputation: 0
How do I use macros with X11 editors?


I'm trying to do some basic macros to format text. For example, I have a list of names and I want to put them in single quotes and comma separated. In my Windows and OS X editors I would just go to some Macros menu and Start Record, do the necessary keystrokes, Stop Record, then playback as needed. That's ideally what I would like to do in editors like gEdit,Kwrite,etc. Right now I'm having to bust out Vim and do something like, :map g i'<End>',<Del><Esc>l

Fine tuning a macro that way is a little more time consuming then I would like, especially for the more complicated macros. Any suggestions?

Eric
 
Old 01-13-2007, 04:06 AM   #2
Simon Bridge
LQ Guru
 
Registered: Oct 2003
Location: Waiheke NZ
Distribution: Ubuntu
Posts: 9,211

Rep: Reputation: 198Reputation: 198
gEdit plugin: snippets - will assign a string to a set of keystrokes (and a context).

search and replace will help with your specific example - you want to replace each newline (\n) with a single quote, followed by a comma, followed by a space, followed by a single quote (,' ,).

Different systems will have different preferred methods for this (i.e. Emacs).
You can especially have a lot of fun with macros in LaTeX.

Last edited by Simon Bridge; 01-13-2007 at 04:13 AM.
 
Old 01-13-2007, 04:35 AM   #3
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
From your description, it sounds like using a regular expression in a substitute command would work out better.
You can precede the "s" command with the range to operate on--
"%s" operates on the entire file. "10,30s" works on lines 10-30. You can save parts of the line that match a pattern using storage registers.
:%s/\([A-Z][a-z]*\) \([A-Z][a-z]*\) /\2, \1/

This will take a list of names like
John Smith
Jane Doe
And convert it to
Smith, John
Doe, Jane
 
Old 01-13-2007, 10:27 AM   #4
Soabirw
LQ Newbie
 
Registered: Aug 2004
Posts: 10

Original Poster
Rep: Reputation: 0
I'll play around with those gEdit plugins, thanks.

I'm sure regular expressions will do most of what I need, they are ver powerful after all. But I have yet to really wrap my head around them. I prefer the macro way because it only takes a few seconds to setup, where it can take me a good 20 minutes to hammer out a regular expression. But maybe this will be a good way to finally beat them into my head.
 
Old 01-16-2007, 08:24 PM   #5
dolsson5
LQ Newbie
 
Registered: Dec 2006
Posts: 2

Rep: Reputation: 0
emacs

Emacs has easy macro record and playback. Don't be frightened of emacs. It's horribly powerful, but the easy stuff is still easy. It's window isn't as pretty as the newer GUI guys, but it's way more powerful and mature.

Start recording: ctrl+x (

End recording: ctrl+x )

Execute recorded macro: ctrl+x e
 
Old 01-17-2007, 09:58 AM   #6
Soabirw
LQ Newbie
 
Registered: Aug 2004
Posts: 10

Original Poster
Rep: Reputation: 0
Thanks, I'll give that a try. I remember a few years ago bouncing between emacs and vim. I liked both for different reasons, but stuck with vim. Of course, this was on the shell. I've never really played with their X11 versions. So I'll give that a try.
 
  


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
Macros In C drumstick Programming 8 11-21-2005 04:37 PM
Core 4 - X11-devel complains about X11-libs which are installed Ephracis Fedora 3 09-05-2005 09:32 AM
Macros Twi7ch Linux - General 2 08-27-2005 09:37 PM
macros file newbielinux Linux - Newbie 1 03-01-2004 11:51 AM
Roaming X11/Xfree86, X11 proxy zapp Linux - Software 1 09-12-2003 08:06 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop

All times are GMT -5. The time now is 01:51 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