5

I can't find an easy solution to the following problem.

Consider I'm in insert mode and I need to modify something in another point of the text. I exit insert mode and then move to the point I need to edit. Now suppose I perform some commands in normal mode. When I'm done I can go back to insert mode in the last insert position with command gi.

The problem comes when the edit I need to do also requires another insert operation. In that case, I would lose the last insert position in mark ^ which makes the gi command useless.

In this case, I would need to jump to the next-to-last insert position. Having a look at :marks, such a mark is not kept. So, what's an easy way to solve this problem?

  • 5
    I guess I found a possible solution with g; and g,. These navigate :changes list. – nicmus Apr 8 '16 at 10:04
1

The simplest solution I can think of is to set the previous context mark m` when leaving insert mode. Then use `` to return to that location after editing elsewhere.

(Note: that those are backtics ` and not normal apostrophes ')
A mapping like :inoremap m` can also be useful.

(edit)
g; and g, should work great too! I'm glad I saw your comment, nicmus.

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.