Tuesday, July 3, 2012

Re: Fold all blocks without TODO in vim notes file

On Tue, Jul 3, 2012 at 6:08 PM, Sepp Tannhuber <sepp.tannhuber@yahoo.de> wrote:
> Hi Salman,
>
> thanks for answering!
>
> For now I use a simple key mapping:
> : map <C-f> <Esc>/TODO<CR>zo
>
> With this method I can unfold block by block with hitting <C-f>.
> Is it possible to automate this on startup so that vi hits <C-f> until it reaches
> end of file?
>
> Cheers
> Joseph:x

You could just do something like:

:au BufRead <TheFileName> g/TODO/foldopen!

However, this is a one-time that will happen automatically when the
file is opened; for a mapping, I would do:

:map <c-f> :g/TODO/foldopen!
:imap <c-f> <c-o><c-f>

This should work for both insert, visual and normal mode. In insert
mode, it will return you to insert mode after the mapping and, in
visual mode, it will limit the effect to the visually selected region.

For help on autocommands, try :help :au, :help BufRead, :help :g and
:help :foldopen.

Salman

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: