Let's say I am typing something, then realize that what I just typed will be repeated a couple of times.

Now, what I would like to do is to select backwards, yank (thereby returning to the position I started from), and immediately paste. However, when my last typed character is also the end of the line, I cannot move the cursor one space over, and going into visual mode starts the selection to the left of the cursor, which means that the last character I typed (usually a brace), will not get copied along with it.

In spite of a long and fruitless search, I cannot come up with any way to start selecting after the cursor instead of in front of it.

In Vim, after all, you have "i" to start inserting before, and "a" to start inserting after the cursor. So if "v" is the equivalent of "i", where is the equivalent of "a" to start selecting after the current character? No cheat sheets or tutorials I looked at had an answer.


That behavior depends on the 'selection' option. You seem to have the (non-default) exclusive; with inclusive, the selection does include the character under the cursor. So toggling that option would be one solution.

If you want to keep it, you could do your backwards selection, then use o$ or ol to go back to the right end and extend it by the missing character.

Or, :set virtualedit=onemore. This will enable you to go beyond the last character in the line and start selecting from there: lv...

Also, the available "inner" text objects often make the need of an explicit selection go away. For example, viw will select the entire last word.

  • The selection option was what I was looking for. Thank you very much indeed. It has been driving me insane. – Mark Anderson Jan 15 '15 at 12:15
  • If I just typed something in vim that I need to type again, I just hit . (but I realize it may not be so simple). – wurtel Jan 15 '15 at 13:09
  • @Costas que? We're talking about vim, not bash, nor bash in vim-mode... – wurtel Jan 15 '15 at 13:57
  • @wurtel Sorry for my unattention. – Costas Jan 15 '15 at 14:21

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.