What is the difference between BufRead and BufEnter?

后端 未结 2 2441
星月不相逢
星月不相逢 2021-02-20 15:41

I am confused between the two events BufRead and BufEnter. What is the difference between them?

Some example scenarios where I would choose one

2条回答
  •  自闭症患者
    2021-02-20 16:44

    A buffer is the in-memory representation of a file; to edit one, it has to be displayed in a window.

    The BufRead event is triggered after Vim has read the file into its memory. Unless you reload via :edit!, this only happens once.

    The BufEnter is fired whenever you activate a certain buffer, i.e. when it becomes the buffer the cursor is in. For example when you have split windows that show different buffers, and you move between then. Also in a single window, when you use a command like , :bnext to change which buffer is currently edited.

提交回复
热议问题