I want to disable `cursorline` when leaving the NERD tree window and enable it when entering the window again. The following setting works fine when using `<C-w>w` or similar, but not when `<CR>`. Hitting `<CR>` opens the file in other window, moves to it, and `cursorline` remains visible. How can I make it work? augroup Cursorline au! au WinEnter * if exists('t:NERDTreeBufName') && bufname("%") == t:NERDTreeBufName | setlocal cursorline | endif au WinLeave * setlocal nocursorline augroup END