Linux - DesktopThis forum is for the discussion of all Linux Software used in a desktop context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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.
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
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.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.