Thursday, October 10, 2019

Re: How to let previous opened fold open reentering vim buffer.

This code well do the calling of func AvoidFolding when entering buffer but it returns E490 no fold found.

fun! AvoidFolding() 
  normal! zx
  normal! zv
  normal! za
endfunction
if has("autocmd")

  " augroup vimrc
  au!
" Avoid folding
autocmd BufEnter *.vim       :call AvoidFolding()
autocmd BufEnter $VIM/_vimrc :call AvoidFolding()
  " augroup END

endif " has("autocmd")


Le mercredi 2 octobre 2019 13:33:56 UTC+2, Ni Va a écrit :

Seems to not working..
It's disturbing that previsou opened fold is closed just when leaving and re entering the same buffer.

Le mercredi 2 octobre 2019 13:12:17 UTC+2, Enno a écrit :
The command `za` toggles the fold. Try instead

silent autocmd! BufEnter *.vim normal! zv

to open sufficiently many folds to show the line where the cursor is at.

Le vendredi 27 septembre 2019 12:58:23 UTC-3, Ni Va a écrit :
Hi,


I try this in _vimrc in order to let a previous opened fold, opened when I re enter buffer.

in _vimrc:
if has("autocmd")
silent autocmd! BufEnter *.vim norm za
endif

example of vim buffer :

function! sequencerutil#echomsg(startreltime,str) abort  " timestamp stolen from codi sorry :){{{
let seconds_and_microseconds = reltimestr(reltime(a:startreltime))
let decimal_i = stridx(seconds_and_microseconds, '.')
let seconds = seconds_and_microseconds[:decimal_i - 1]
let microseconds = seconds_and_microseconds[decimal_i + 1:]
let timestamp = strftime("%T.".microseconds, seconds)
echomsg strftime('%Y/%m/%d %T.').printf("%.3s",microseconds).printf(" %.3s secs %s", seconds, a:str)
endfunc "}}}
" vim: set ft=vim ff=dos fdm=marker ts=4 :expandtab:



It seems to not doing what I attempt but why ?

Thanks in advance.
NiVa

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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/89c21ec9-48c8-43dd-b42a-ea39383c2b35%40googlegroups.com.

No comments:

Post a Comment