" 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\+\%#\@ " Adjust the colorcolumn together with &textwidth autocmd OptionSet textwidth exec 'set cc=' . v:option_old . ' | set cc+=' . &tw " " Highlight word under cursor augroup highlight_current_word au! au CursorHold * :exec 'match CursorColumn /\V\<' . escape(expand(''), '/\') . '\>/' au CursorMoved * :exec 'match' augroup END