3

I just accidentally did f], how do I return the cursor to where it previously was?

Ctrl-O doesn't work of course because f is not regarded as a jump.

, doesn't work because I wasn't on a ] previously.

minseong
  • 2,313
  • 1
  • 19
  • 38
  • I do believe you can remap it, and save the lastpos register to allow for ctrlO. I don't know if recommended. – eyal karni Dec 08 '20 at 12:21

2 Answers2

2

You can't.

But f only works in the current line, so you must be near anyway. This also true in general: if motion doesn't appear in the jumplist then it is probably an intra-line motion.

Matt
  • 20,685
  • 1
  • 11
  • 24
1

Use the plugin Houl/repmo, to extend these abilities by providing pairs of forward and reversed(backward) motions. Like [s, ]s. It usually overrides the normal keys for repeating motion ;, ,.

Notice that you can't exactly undo f], but it does F], which mostly is good enough. It is better in the example I gave (next/prev spelling error).

eyal karni
  • 1,106
  • 9
  • 33