1

Hi Vi StackExchange,

A Picture of what I want

Say I have the following in my buffer:

foo("a", "bar")

And I am in normal mode with my point on b in bar.

Now I want to insert some characters, say xyz before bar. So I press:

ixyz<esc>

Then that leaves my point on z.


What I want is something that I can press to go to the start of the last insert some magic key <magic key> such that:

ixyz<esc><magic key>

Leaves me with my point at x.

I will then proceed to map the composition <esc><magic key> as a secondary exit for me to use.

  • Why do you want to go to the start of the insert? A clearer understanding of what is being accomplished might help design the solution (gi and the . mark came to mind but dont fit your needs) – D. Ben Knoble Jun 19 '18 at 13:21
  • There's the ^ mark, but that will leave you on the b, which is where the cursor was before you started insert mode, but with a different logic than what you describe (not absolute). – Martin Tournoij Jun 19 '18 at 13:55
0

After performing an insert the marks '[ and '] are set to the start character and just past the end of the inserted text.

A map like this should work:

inoremap <c-l> <esc>`[

which just leaves insert mode then goes to the '[ mark.

You can also go to the mark without leaving insert mode;

inoremap <c-l> <c-o>`[

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.