WinEnter
WinEnter is an autocommand event in Vim and Neovim that fires when the focus switches to a different window. It is part of the window-related events that allow per-window customization as users navigate splits, tabs, or other window arrangements.
The event is typically used to adjust window-local options or apply context-specific behavior as the active
In Vimscript, you can attach actions to WinEnter with an autocmd. For example:
autocmd WinEnter * setlocal cursorline
autocmd WinEnter * setlocal number
In Neovim, the same can be written in Lua using the API:
vim.api.nvim_create_autocmd("WinEnter", { pattern = "*", callback = function()
WinEnter is commonly used alongside WinLeave, BufWinEnter, and other window events to manage per-window state as