From vim Sun Dec 29 21:47:18 2002 From: Emmanuel Touzery Date: Sun, 29 Dec 2002 21:47:18 +0000 To: vim Subject: Re: automatically opening folds X-MARC-Message: https://marc.info/?l=vim&m=104119844713138 Hello, =09This code works perfectly :O) =09However the foldmethod was not set by a modeline but in the filetype p= lugin=20 (which is maybe set late also in file opening stage, i'm not too sure). =09Anyway, thank you very very much... one thing less on the path to the=20 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 even= t > is triggered before the modelines are processed. > > This code should do it: > > autocmd BufReadPost * > \ if line("'\"") > 0 && line("'\"") <=3D line("$") | > \ exe "normal g`\"" | > \ let b:doopenfold =3D 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