[prev in list] [next in list] [prev in thread] [next in thread] 

List:       vim
Subject:    Re: automatically opening folds
From:       Emmanuel Touzery <emmanuel.touzery () wanadoo ! fr>
Date:       2002-12-29 21:47:18
[Download RAW message or body]

Hello,

	This code works perfectly :O)

	However the foldmethod was not set by a modeline but in the filetype plugin 
(which is maybe set late also in file opening stage, i'm not too sure).

	Anyway, thank you very very much... one thing less on the path to the 
absolutely-perfect-for-me editor :O)

emmanuel

On Sunday 29 December 2002 22:39, Bram Moolenaar wrote:
> I assume the 'foldmethod' is being set by a modeline.  In that case you
> need to execute the "zv" command with a BufWinEnter autocommand, but
> only when the `" command was used.  That's because the BufReadPost event
> is triggered before the modelines are processed.
>
> This code should do it:
>
>   autocmd BufReadPost *
>     \ if line("'\"") > 0 && line("'\"") <= line("$") |
>     \   exe "normal g`\"" |
>     \   let b:doopenfold = 1 |
>     \ endif
>   " Need to postpone using "zv" until after reading the modelines.
>   autocmd BufWinEnter *
>     \ if exists("b:doopenfold") |
>     \   unlet b:doopenfold |
>     \   exe "normal zv" |
>     \ endif

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic