diff --git a/.config/vim/vimrc.d/30-settings.vim b/.config/vim/vimrc.d/30-settings.vim index 6b09661..a6d647f 100644 --- a/.config/vim/vimrc.d/30-settings.vim +++ b/.config/vim/vimrc.d/30-settings.vim @@ -77,11 +77,11 @@ if (has('cmdline_info')) endif " Show whitespace characters set list -set listchars=tab:>· +" Display tabs and trailing space characters as well an indicator for long lines +" when not wrapping +set listchars=tab:>·,trail:·,extends:> " Wrap lines set wrap -" When wrap is off, show a visual indicator that the lines continues -set listchars+=extends:> " Keep current line away from top/bottom borders of the buffer when scrolling set scrolloff=5 " Enable mouse diff --git a/.config/vim/vimrc.d/50-looks.vim b/.config/vim/vimrc.d/50-looks.vim index 81b1fed..1e48a34 100644 --- a/.config/vim/vimrc.d/50-looks.vim +++ b/.config/vim/vimrc.d/50-looks.vim @@ -46,12 +46,21 @@ if (get(g:, 'loaded_fzf')) endif " Highlight trailing whitespaces -" Pattern taken from https://vim.fandom.com/wiki/Highlight_unwanted_spaces -highlight TrailingWhitespace ctermbg=red guibg=red +if match(&listchars, 'trail: \@!') > -1 && match(&listchars, '\vtab:( +)@!') > -1 + " Use foreground for coloring if tabs and trailing spaces are displayed + " as non-space characters + highlight TrailingWhitespace ctermfg=red guifg=red +else + " Background otherwise + highlight TrailingWhitespace ctermbg=red guibg=red +endif augroup HighlightTrailingWhitespace au! - " NOTE: VimEnter is necessary as well as WinNew is not triggered for the - " first window created after startup (see :help WinNew) + " Pattern taken from + " https://vim.fandom.com/wiki/Highlight_unwanted_spaces + " + " NOTE: VimEnter is necessary as well, since WinNew is not triggered for + " the first window created after startup (see :help WinNew) au VimEnter,WinNew * call matchadd("TrailingWhitespace", '\s\+\%#\@