3

Typical mark placement using m places the mark at the cursor. When the cursor is on the last character of a line, this means that jumping to that mark for the purpose of copying text starts the copying before the last character of the line.

For instance, if I have the sentence Vim is a great editor. and place a mark with my cursor on the . using ma, then move up some number of lines and hit y`a, I yank those lines plus Vim is a great editor but not the entire sentence.

Is there a way to place a mark after the period so that I can yank the entire line in situations like this?

I realize that if I never add more characters to that particular line, I can use y'a, but sometimes I want to maintain the flexibility to add more characters later.

If this is not possible, are there other features of Vim I can use to accomplish the same thing? For instance, is there some "yank until after cursor" command?

4

I found the answer here.

Another easy way is to just add v right after y, no setting or Visual mode selection necessary.

`a"ryv`b

y`b yanks to mark b excluding the character under mark b, whereas yv`b yanks to mark b including the character under it.

See :h o_v for more info.

| improve this answer | |

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.