When I first started using Vim 10 years ago, I found myself typing


a lot. I was used to using 'a and 'f as my go-to marks. So I also had this in my .vimrc:

map qq :'a,'f

Are there any special kinds of marks in Vim that act more like "quick" or "temporary" marks, accompanied by a shortcut or notation that means "the last two quick-marks"?

I looked through the documentation on marks but did not see any. Does anyone have a more elegant shortcut than mine?


1 Answer 1


Using 2 marks to operate on the text between those lines is the 'vi'-compatible way of the more modern and (literally) visual way of operating in Vim (and probably why visual mode was invented in the 1st place): visually select a range with whatever means (motion, text-object), then start your ex command, which operates line-wise: when you hit :, you will see those two quick marks automatically inserted before the : (the start and the end marks of the visual selection).

Quick access to "the last two quick-marks" in this case would translate to "restoring the last visual selection", which can be accomplished with gv.

And now for the funny part: if you really want it, you can explicitly set those two marks (< and >), manually, using m< and m>, as with any letter-based mark. I.e. you don't need to go to visual mode for that; then, either use gv to restore that selection and start your ex command, or manually insert :'<,'>some-ex-command-here to (similarly) operate on that line range. In another words, visual marks can operate exactly as in your request (quick or temporary marks that can be set - a pair of them), with the advantage of also allowing a more visual way of assignation.

So, maybe this mapping, to execute on a selection:

noremap g: gv:
  • 5
    Also note that :* is an abbreviation for :'<,'> Oct 26, 2016 at 12:09
  • That's interesting (and I can't find where it is documented).
    – VanLaser
    Oct 26, 2016 at 12:40
  • 1
    Yeah, difficult to find: :help cpo-star Oct 26, 2016 at 13:12
  • Odd, m< and m> don't work for me. '< says "E20: Mark not set". Oct 26, 2016 at 14:02
  • 1
    @AndrewCheong Yes that is too old. I think settable marks for the visual selection was in a late 7.3 patch Oct 26, 2016 at 18:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.