Idea I will like to construct a simple emacs function that copies the yy
functionality in vim.
The function should yank a visual-line into kill ring without deleting the line.
Function Here is the function I came up with.
(defun vim-line-yank-func()
(interactive)
(beginning-of-visual-line)
(mark-end-of-sentence 1)
(end-of-visual-line)
(copy-region-as-kill (mark) (point))
)
Let us run this program on some data. Consider the following text with original line breaks (► is position of the mark "\n" = newline mark).
Pellentesque dapibus suscipit ligula. ► Donec posuere augue in quam. Etiam \n
vel tortor sodales tellus ultricies commodo. Suspendisse potenti. \n
Aenean in sem ac leo mollis blandit.
The expected answer is
Pellentesque dapibus suscipit ligula. Donec posuere augue in quam. Etiam
but the answer I keep getting is the following:
Donec posuere augue in quam. Etiam
I am befuddled as to why this is happening. When I run these commands in succession things seem to work fine. Thank you for your help!
mark-end-of-sentence
, which sets the mark at the end of the sentence (forward from point). And then you move point to the end of the line. So the region is between point (end of line) and mark (end of the first sentence). See Stefan's answer, which just removes the call tomark-end-of-sentence
.