I've found if do :set number, I can fold between specific lines x and y with xGzfyG or easier for me xggzfygg. That's great but it's a distraction to find the line numbers as is [visual]zf. I use marks a lot and know I can do a colon command :'a,'bfo. Is there any zf shortcut in normal mode using marks ?

This is not for regular text objects, else I would use one the related motion commands.

  • Why not create your own normal mode shortcut? E.g. just using your example command: :nnoremap <leader>zf :'a,'bfo<cr>
    – B Layer
    Commented Dec 31, 2021 at 18:01
  • Welcome to Vi and Vim!
    – filbranden
    Commented Dec 31, 2021 at 18:10
  • 1
    Thank you. \zf is an interesting one as I use 'a and 'b the most but it took me a moment to figure out I needed to do it quickly. The issue of course is the marks may not be a or b.
    – chipfall
    Commented Dec 31, 2021 at 19:40

1 Answer 1


The zf Normal-mode command takes a motion, and moving to a mark is a valid motion. So 'azf'b is a valid command to create a new fold in the range between marks 'a and 'b, and it's equivalent to :'a,'bfo.

Other than that, if you want to dedicate a couple marks (such as 'a and 'b in your example) and always use them as beginning and end of the region to fold, then you can create a one or two key mapping to fold the region enclosed by those marks.

Or use a single fixed mark, and the current line as the other boundary in your mapping. For example, use ma to mark the beginning, then navigate to where you want the end of the fold and use zf'a, or a shorter mapping you create for the zf'a command.

  • 1
    This was it and I could not see it. I think I was trying to mix in the g command. Thank you. Upvoted but I don't think it counts.
    – chipfall
    Commented Dec 31, 2021 at 19:41

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.