commit 5775d05a75649ec567286829615fbb7473ec9ab2
parent cf153b67d6b1c3d4ecb4131626f099ac5a7f6aab
Author: Bharatvaj H <bharatvaj@yahoo.com>
Date: Tue, 3 Aug 2021 01:00:29 +0530
vimrc: Adaptive line numbers
Diffstat:
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/.config/vim/vimrc b/.config/vim/vimrc
@@ -17,7 +17,15 @@ set undodir=$XDG_CACHE_HOME/vim/undo | call mkdir(&undodir, 'p')
if !has('nvim') | set viminfofile=$XDG_CACHE_HOME/vim/viminfo | endif
" General
-set number! relativenumber!
+
+"Adapted from https://jeffkreeftmeijer.com/vim-number/
+:set number
+:augroup numbertoggle
+: autocmd!
+: autocmd BufEnter,FocusGained,InsertLeave,WinEnter * if &nu && mode() != "i" | set rnu | endif
+: autocmd BufLeave,FocusLost,InsertEnter,WinLeave * if &nu | set nornu | endif
+:augroup END
+
set mouse=a
syntax on
set exrc