Copying the previous line to current position in Emacs
Recently, I came across a scenario where I had to quickly copy the previous line in an Emacs buffer to the current position. The usual method for doing this has been to invoke: C-p C-a C-k C-y RET C-y Which basically does the following: Moves to the previous line (C-p) Moves to the beginning of the previous line (C-a) Kills the line (i.e., cuts the line with C-k) Yanks the line back (i.e., restores the original line with C-y) Creates a newline (RET), and Yanks another copy of the line with the final C-y (which is what we wanted in the first place) While this works, it is certainly not the most optimal mechanism to perform such a simple (albeit infrequent) operation. ...