From 078426c90148ec7d67d02d0d1b1fb3e25af502da Mon Sep 17 00:00:00 2001 From: Stefan Huber Date: Thu, 31 Oct 2019 20:30:56 +0100 Subject: [PATCH] init: BadWhitespace only for non-readonly --- init.vim | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/init.vim b/init.vim index e552eff..17ed253 100644 --- a/init.vim +++ b/init.vim @@ -48,11 +48,23 @@ runtime plugsetup.vim " Attention: Must be run after plugsetup.vim " Trailing whitespace highlight default link BadWhitespace SpellCap + +" Setup BadWhitespace syntax match expressions. +function SetBadWhitespaceSyntax() + " Do not expose bad whitespace in help buffers or for man pages. Or, more + " generally, if we open the file readonly. + "if &ft != "help" && &ft != "man" + if !&readonly + " Make trailing whitespace be flagged as bad. + syn match BadWhitespace /\s\+$/ containedin=ALL + " Make space before tab be flagged as bad and vice versa + syn match BadWhitespace / \+\t/ containedin=ALL + syn match BadWhitespace /\t \+/ containedin=ALL + endif +endfunction + " Make trailing whitespace be flagged as bad. -au BufRead,BufNewFile * syn match BadWhitespace /\s\+$/ containedin=ALL -" Make space before tab be flagged as bad and vice versa -au BufRead,BufNewFile * syn match BadWhitespace / \+\t/ containedin=ALL -au BufRead,BufNewFile * syn match BadWhitespace /\t \+/ containedin=ALL +au BufRead,BufNewFile * call SetBadWhitespaceSyntax() let g:airline_powerline_fonts=1 let g:airline#extensions#tabline#enabled=1 -- 2.30.2