I use
C-a C-SPACE C-n M-w C-y
which breaks down to
C-a
: move cursor to start of line
C-SPACE
: begin a selection ("set mark")
C-n
: move cursor to next line
M-w
: copy region
C-y
: paste ("yank")
The aforementioned
C-a C-k C-k C-y C-y
amounts to the same thing (TMTOWTDI)
C-a
: move cursor to start of line
C-k
: cut ("kill") the line
C-k
: cut the newline
C-y
: paste ("yank") (we're back at square one)
C-y
: paste again (now we've got two copies of the line)
These are both embarrassingly verbose compared to C-d
in your editor, but in Emacs there's always a customization. C-d
is bound to delete-char
by default, so how about C-c C-d
? Just add the following to your .emacs
:
(global-set-key "C-cC-d" "C-aC- C-nM-wC-y")
(@Nathan's elisp version is probably preferable, because it won't break if any of the key bindings are changed.)
Beware: some Emacs modes may reclaim C-c C-d
to do something else.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…