(global-set-key (kbd "C-S-d") 'duplicate-current-line) smart copy region ( when (or (= 1 (forward-line 1)) (eq (point) (point-max))) when on last line, insert a newline first "duplicate current line, make more than 1 copy given a numeric argument" ( defun duplicate-current-line ( &optional n) I ( dim) am doing that instead: duplicate current line ( progn ( if arg (forward-visible-line arg) Text before point to the beginning of the current line." With a prefix argument, copy that many lines from point. "Copy to the kill ring from point to the end of the current line. – avi ( defun avi-kill-line-save ( &optional arg) As of now I use both functions with different keys, depending on the situation i need them. What I’d like to expand it with is the possibillity to be able to call it consecutively and copy multiple lines one for one, as quick-copy-line does, and let this behaviour depend on a variable or a prefix. This one behaves the same way as ‘kill-line’, except that it doesn’t move point at all, because I felt that it suits me the best this way. There are C-w ( kill-region) and M-w ( kill-ring-save), but C-k ( kill-line) doesn’t seem to have a counterpart that just saves the lines into the kill ring. I too always wondered why stock Emacs didn’t have a convenient line copying keybinding, or even a function. This is the same behavior as hitting `’, the binding for ‘kill-whole-line’. Similar to the quick-copy-line, I define the function quick-cut-line to quickly cut multiple lines and append them to the kill-ring. (kill-append (buffer-substring beg end) (< end beg)) Consecutive calls to this command append each line to the kill-ring." This makes it really quick and easy to copy multiple lines. Hitting multiple times appends each line to the kill ring (which is why the command moves to the beginning of the next line). (kill-append (buffer-substring beg end) (. (setq end ( save-excursion (goto-char (mark)) (line-end-position))))) (setq beg ( save-excursion (goto-char (mark)) (line-beginning-position))) Use newline as last char even on the last line of the buffer. "Copy lines (as many as prefix argument) in the kill ring. Modify the vanilla commands, for some context-dependent behavior.īest overall imo for adding to standard emacs ( defun copy-line (arg).It can then be bound to a shorter key sequence, e.g., ‘ C-c C-k’. Define a new command for copying the current line.This section presents some additional ways to copy a line, besides those available out of the box. You can also copy whole lines using Viper: yy (current line), yj (current + next etc.). In the key sequences above, ‘C-a’ goes to beginning of line, ‘C-e’ goes to the end of line, ‘C-n’ goes to the next line, ‘C-SPC’ sets the mark, ‘M-w’ saves the region, ‘C-k’ kills from point to the end of line, and ‘C-y’ yanks the last kill back. ‘C-S-backspace C-y’ Kills an entire line at once ( kill-whole-line) and yanks it back.‘C-a C-k C-/’ kills the line without newline if kill-whole-line is nil, or including the newline otherwise.But this cause Emacs thinks the buffer is modified. ‘C-a C-k C-y’ kills and yanks back the line without newline if kill-whole-line is nil, or including the newline otherwise.If kill-whole-line is non- nil, it saves two lines. ‘C-a C-k C-k C-y’ kills the line with newline and yanks it back, in effect saving it to the kill ring.‘C-a C-SPC C-n M-w’ copies the current line, including the newline.‘C-a C-SPC C-e M-w’ copies the current line without the newline.You can also use either of these mouse selection methods to select whole lines as the SecondarySelection – just hold down the Meta key while you click. Click ‘mouse-1’ at the the start of the line, then click ‘mouse-3’ at the start of the next or previous line.Triple-click ‘mouse-1’ somewhere on the line.There are various ways to copy the current line to the kill ring in vanilla GnuEmacs:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |