Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way to select (or paste) text without trailing/ending whitespace?

eg. To copy the whole line I press y, to paste it somewhere else I use p, but it pastes the whole text with the trailing EOL character too.

The same case using Windows standard:
home, shift+end, ctrl+c, ctrl+v
(allows me to paste the selected text inline)

I'd like to have similar behavior in vim.
I'd like to avoid any macros, as I'm using PHPStorm plugin emulating vim, so not all sophistocated command are working there.

share|improve this question

Instead of yanking the entire line (with the trailing newline) with yy, use 0y$ instead.

If you want no surrounding whitespace at all, _yg_ would be possible in Vim.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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