1

I'm quite used to the very basic action of inserting some text, entering normal mode, moving to somewhere else I'd like the same text, and hitting . to do so.

This doesn't work if the insert needs to be right at the end of a line though, as in normal mode you can't move the cursor far right enough, and the insert will happen before the existing last character of the line.

What's the solution?

3
  • 3
    Couldn't you just use a (or A) instead of i? Or do you not know in advance in which locations you'll be inserting the text? Commented Jan 24, 2023 at 9:00
  • 3
    The solution is to be mindful about your edits and make them repeatable by default. It comes with practice and I'm afraid there is no easy recipe for that. In this case, using a instead of i might be a good start. Or A<C-a>? Anyway, the more commands you know, the better you will be at picking the right one. Commented Jan 24, 2023 at 9:02
  • It's strange. When I started with vim I regularly used a....... and at some point my brain seems to have forgotten it and I've always defaulted to i instead. 🙄 Commented Jan 24, 2023 at 9:30

1 Answer 1

2

Proper answer

You can enter Insert mode after the cursor position with a. Or use A to enter Insert mode at the end of the line.

This was answered by Rich in a comment below the question.


Original answer

With :set virtualedit=onemore you would be able to move the one extra space to the right.

When I wrote the above, I assumed that the obvious solution above was not applicable for whatever reason.

2
  • Thanks Friedrich, I assumed there would be a 1 or 2 keystroke combination that would do what I wanted, but a global setting is maybe a good solution. Though I think @Rich is right in the comment on my question, and I should just have known that a was a thing 🙄 Commented Jan 24, 2023 at 9:29
  • 1
    @Codemonkey using a is probably the better solution. Judging from your question I assumed it was not applicable. Commented Jan 24, 2023 at 9:32

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.