BufEnter
BufEnter is an autocommand event in Vim and Neovim that fires when a buffer becomes the active buffer in a window. It runs after the buffer is shown in the current window, and it is commonly used to apply buffer-local options, initialize state, or trigger actions that should occur whenever you switch to that buffer.
Related events include BufWinEnter and BufLeave. BufWinEnter fires when a window displaying a buffer becomes active,
Typical usage involves defining autocommands that adjust behavior on a per-buffer basis. For example, you might
Because BufEnter can fire frequently as you navigate between buffers, it is common to limit commands with
See also BufLeave and BufWinEnter for related lifecycle events, as well as general autocommand usage and per-buffer
---