I need an example to differentiate the two events in Vim, as I'm having a hard time understanding them.

1 Answer 1


This difference is pretty obvious:

  • BufEnter X:
  1. It was bufnr() != X
  2. But now it becomes bufnr() == X
  • BufWinEnter X:
  1. It was len(win_findbuf(X)) == 0
  2. But now it becomes len(win_findbuf(X)) == 1
  • It's very clear now! I forgot the fact that a buffer in multiple windows! Thank you! Dec 28, 2021 at 14:55
  • I would have written empty(win_findbuf(X)), but NBD.
    – D. Ben Knoble
    Dec 28, 2021 at 15:55
  • 1
    @D.BenKnoble To me it rather clearly states "from zero to one". But de gustibus...
    – Matt
    Dec 28, 2021 at 16:13
  • Good answers are always worth reviewing. I just forgot about their difference... Nov 30, 2022 at 17:40

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.