In emacs off late I have had to write some lines of code which are quite repetitive in nature. Consecutive lines are almost exactly the same except for some trivial modifications.
Is there a keystroke in emacs by which the line the cursor (point) currently on gets duplicated onto the next line. To generalize this, if I could specifiy which line number
onto which I want to paste the current line, that would also be great.
I tend to use the following:
Select a region, and then
C-x r x. Where r is the name of the register; a single character on your keyboard can serve as the register.Then
C-x g rwhere you want to insert whatever line you saved in register r.You can bind these 2 commands to shortcut keys to make your task even easier.
The benefit of using registers is that you can save different lines in different registers and recall them at any time. Also if you do
C-kand kill a line, it won’t interfere with your saved registers.I hope that helps.