From 01ebc211bbd09b409ece60b9153864ce6c92dc53 Mon Sep 17 00:00:00 2001 From: Julian Prein Date: Fri, 17 Jun 2022 15:06:12 +0200 Subject: [PATCH] vim:autocmd: Disable relative numbers in insert As relative line numbers are only really needed in normal mode and in the current buffer, disable them in insert mode or when the buffer/window is not focused. --- .config/vim/vimrc.d/80-autocommands.vim | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.config/vim/vimrc.d/80-autocommands.vim b/.config/vim/vimrc.d/80-autocommands.vim index 307327f..3b9f323 100644 --- a/.config/vim/vimrc.d/80-autocommands.vim +++ b/.config/vim/vimrc.d/80-autocommands.vim @@ -63,3 +63,9 @@ augroup highlight_current_word au CursorHold * :exec 'match CursorColumn /\V\<' . escape(expand(''), '/\') . '\>/' au CursorMoved * :exec 'match' augroup END + +augroup numbertoggle + au! + au BufEnter,FocusGained,InsertLeave,WinEnter * if &nu | set rnu | endif + au BufLeave,FocusLost,InsertEnter,WinLeave * if &nu | set nornu | endif +augroup END