I'm trying to write a very simple function to replicate the Vim 'p' command. This is, paste some text after the current line.

I've been googling for a while and haven't found a function to achieve this, which I think it's very strange as I consider this quite handy!

I'm aware of the awesome Evil-mode, but I just require only this functionality to be happy :-)

So far this is what I have:

(defun paste-after-line ()
  (prelude-smart-open-line nil) ;; This function opens a new line below

It works, but if the copied text has a line ending, then the yanked text also adds an empty line below the text and places the cursor there.

Does anyone knows if is there a way to yank some text excluding any new line on it?



There is a wonderful function named delete-blank-lines.

(defun paste-after-line ()
  (move-end-of-line nil)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.