What is the difference between BufRead and BufEnter?

后端 未结 2 2432
星月不相逢
星月不相逢 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:32

    BufRead is triggered after the buffer has been populated with the content of a file.

    BufEnter is triggered after you enter a buffer for editing.

    You may use BufNew, BufRead or BufAdd if you want to do something upon the creation of the buffer: setting some global variable, populating a buffer list of your own for use in a script.

    You may use BufEnter when you want to set specific options depending on the filetype or whatever.

提交回复
热议问题