The service will be shut down on April 1st. Please see this page for more information.



Home > ComputerStuff > Software > Programming > ProgrammersTools >Editors > Emacs > Cua-Mode | Contact.

Say you have this


And you want to have this

Well, easy. Copy the string [[Image(grep_1.png)]] (use C-space, C-e, M-w). Enter cua-mode M-x cua-mode, then hit C-Enter to start a rectangle. Create a rectangle of 6 lines by 1 column, like so :

Then hit M-s to insert a string. You can paste the string [[Image(grep_1.png)]] here with C-y, you should get this :


But we need different values right ? we want grep_1, grep_2, grep_3 etc. Easy. Exit the rectangle-selection mode by hitting C-Enter again, and go to the first 1 (on first line), then start a new rectangle again with C-Enter, you then select that column on all lines, like so :


Now Type M-n to insert a sequence, starting from 1 and incrementing by 1. You get this as a result :



EDIT : somebody on reddit (prakashk) expressed his opinion about emacs article not giving what key sequences are bound to because M-n didn't do anything in his configuration. As I have replied there, one must be in cua-mode and have started a rectangle with C-Enter in order for M-n to be bound to the cua-sequence-rectangle function

EDIT2 : another guy [WWW]posted a shorter macro-based solution on his blog.

To comment or ask questions, you may prefere to Contact me directly, as I get no notification when you post a comment in here.

[WWW]Je suis parrain Linux

Si vous êtes dans ma région et que avez besoin d'aide pour installer linux, vous pouvez me contacter
Sinon, [WWW]vous pouvez chercher un parrain dans votre région.


Note: You must be logged in to add comments

This is a Wiki Spot wiki. Wiki Spot is a 501(c)3 non-profit organization that helps communities collaborate via wikis.