2

I have a line of vimscript in my buffer like:

call MyFooFunction(1,2)

and I'm trying to execute it quickly.

So, I yank it (yy), invoke the command line (:), and paste it in with <C-r>"

But, after I paste, I see an extra ^M at the end:

:call MyFooFunction(1,2)^M

What is this extra ^M character and how do I not have it included when I paste?

5

That extra character is a newline. yy copies both the contents of the line and the line break. To copy a line without the line break, you can do 0y$. 0 moves to the beginning of the line, and y$ yanks until the last character of the line. If you want to, you could map it to make it faster:

nnoremap Y 0y$

Y is a synonym for yy by default, so it is okay to map over it. You can map it to whatever key you prefer though.

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.