# Can vim treat a folded section as a motion?

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)?

\begin{equa|t|ion}%{{{
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.

-
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:

ciz
diz
viz
yiz

-

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.

-