Reputation: 2527
in VIM, I understand that we can do a yank till the end of line using y$
but if e.g. my text is abcdefg
and my cursor is at 'g' and I enter y^
the line will be copy without the g. My idea is to copy the whole line without the line break, any similar action will do.
Upvotes: 18
Views: 6743
Reputation:
Turns out yanking till end of line is a thing you'll find yourself doing quite often. As such, the following mapping is quite popular.
noremap Y y$
It's so popular, it's even listed under :h Y
!
If you use this mapping, the answer to your question would be 0Y
Upvotes: 3
Reputation: 5198
If all the characters are indeed together and conform to a "vim sentence", you could use visual selection for the sentence
object. A sentence
in this case would match abcdefg
even if that is not starting at the beginning of a line and it will not include the line ending:
visy
If you want to include trailing whitespace you would use a
instead of i
(mnemonic for "inside"):
vasy
The only problem with this approach (which may be what you do not want) is that it will not include leading whitespace. So if you have something like:
abcdefg
The selection will not include the leading chunk of whitespace, just abcdefg
.
Upvotes: 3
Reputation: 20640
Making it a visual selection and then yanking that includes the character under the cursor:
v0y
Upvotes: 7
Reputation: 159
0y$$ - copy the line without line break and move cursor back to the end
Upvotes: 12