" Autocommands """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Highlight trailing whitespaces " (https://vim.fandom.com/wiki/Highlight_unwanted_spaces) " Create highlight group highlight ExtraWhitespace ctermbg=red guibg=red " Associate with patter (trailing whitespaces) match ExtraWhitespace /\s\+$/ " apply not only to the first window autocmd BufWinEnter * match ExtraWhitespace /\s\+$/ " Do not match when typing at the end of a line autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@ " Highlight word under cursor augroup highlight_current_word au! 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