3

I got:

set shada=!,'100,<50,s10,h,f1,s100,%

Which make Vim reload last buffers when I exit (or :wshada was called ) .

However, the buffers are loaded without syntax and highlighting. I need to reload each buffer, and :bufdo :e didn't work.

I wish to somehow reload all buffers on start.

3
  • Are the filetype of the loaded buffers correctly detected? Dec 15, 2022 at 10:12
  • I don't understand the question. What problem are you trying to solve? Isn't Syntax highlighting activated as soon as you actually jump to one of those buffers? Dec 15, 2022 at 12:22
  • No, it doesn't, @ChristianBrabandt. No.
    – eyal karni
    Dec 16, 2022 at 15:29

2 Answers 2

3

I would suggest you:

:windo filetype detect
8
  • 2
    that should be bufdo? shouldn't it? Dec 15, 2022 at 12:22
  • I have in my vimrc: autocmd SessionLoadPost * windo filetype detect and it works at detecting the first split file type but not the other split file type :-|. With autocmd SessionLoadPost * bufdo filetype detect it does not work. Unless I run it manually when the GUI is loaded. I never manage to find an event to make it working perfectly. Dec 15, 2022 at 12:37
  • I realize that I have that odd behavior only when Startify is active. I don't know if that is also the problem of @eyal. Dec 15, 2022 at 14:02
  • 1
    Good direction at least. I thought it works, it does solve folding (bufdo), but not highlighting. windo works on the current displayed window. I think maybe on bufferenter, but it might not be great in terms of performance. I think it only reload highlighting if it is currently displayed.
    – eyal karni
    Dec 16, 2022 at 15:26
  • Do you confirm that you are also using Startify? Dec 16, 2022 at 15:30
2

My solution based on @vivian

function! OnWinEnter()
    if !&filetype
        filetype detect
    endif
endfunction
autocmd BufWinEnter * call OnWinEnter()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.