For those of you who want to do this for more complex scenarios and want to do this without installing a new module, please read. (This is possible in Emacs without installing MarkMultiple, although I personally use and love MarkMultiple)
Recently, I had to output an SQL query to a file, and then format it in a MYSQL INSERT query. This is how Emacs made my life easier.
The file looks like this:
1 I am a random text 2 I am not 3 G, you've gone mad 4 Click on this link 5 Transfer in progress (we've started the transfer process) 6 But transfer happend yesterday 7 No you are 8 Oh please! this is getting too much! 9 I love emacs 10 I cant be bothered with this any more 11 its time to raise the bar 12 show me how to expand my territory
And I want it to look like this:
(1, ,'I am a random text'), (2, ,'I am not'), (3, ,'G, youve gone mad'), (4, ,'Click on this link'), (5, ,'Transfer in progress (weve started the transfer process)'), (6, ,'But transfer happend yesterday'), (7, ,'No you are'), (8, ,'Oh please! this is getting too much!'), (9, ,'I love emacs'), (10, ,'I cant be bothered with this any more'), (11, ,'its time to raise the bar'), (12, ,'show me how to expand my territory'),
- Place the cursor on the first line
- Press
Cx ( to start recording the macro [At this point, all your key inputs are recorded so carefully follow the instructions] - Press
Ca to go to the beginning of the line - Type "(", then
Mf to move the word, and then type "," Cn to go to the next line and then Cx ) to complete the macroCu 11 Cx e repeat the macro n (11 in this case) times
Eureka! Now, if you have not failed, you will get something similar to this:
(1, I am a random text (2, I am not (3, G, youve gone mad (4, Click on this link (5, Transfer in progress (weve started the transfer process) (6, But transfer happend yesterday (7, No you are (8, Oh please! this is getting too much! (9, I love emacs (10, I cant be bothered with this any more (11, its time to raise the bar (12, show me how to expand my territory
At this moment, I am going to leave you to find out the rest. But, before I go, I would like to mention that there are many ways to achieve this kind of thing. This is just one of these ways, and it happens to be my favorite way.
I hope you found this useful;)