Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a folded section in a text document. Can I use the fold as a motion in vim, in the same way a word or WORD is a motion with w/W?

For example daw deletes around a word, so

This is a |t|est

with the cursor in ||, and in normal mode if I run the command daw will become

This is |a|

Can I do this with a folded section (using foldmethod=marker, and latex code)?

a = 10

after the fold motion would be deleted. Is this possible in other foldmethod modes?

For my question I know I can just fold the section then delete the "line", but I was wondering if the fold itself can be treated as a motion.

share|improve this question
This would be a motion independent of whether the fold is folded or not – Simon Walker Apr 5 '13 at 12:06
Did you try daw on a closed fold? – romainl Apr 5 '13 at 13:33

I'm not aware of such a thing in Vim. But one can use [z and ]z to jump to the beginning and end of a fold.

This seems to do the trick:

xnoremap iz :<C-U>silent!normal![zV]z<CR>
onoremap iz :normal viz<CR>

You can use it like iw and friends:

share|improve this answer

Take a look at the vim-textobj-fold plugin. It provides text objects for foldings, which I think is exactly what you are asking for.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .