From 94fa92b441fca82dc2eb334f23938847867546f5 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Fri, 26 Feb 2010 21:24:46 +0000 Subject: Improve the vim code for highlighting trailing whitespace and lines longer than 80 columns. This replaces the heavy-handed "textwidth" mechanism, and makes the trailing-whitespace highlighting lazy so that it isn't constantly jumping on the user during typing. llvm-svn: 97267 --- llvm/utils/vim/vimrc | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'llvm/utils/vim') diff --git a/llvm/utils/vim/vimrc b/llvm/utils/vim/vimrc index 4909f602cff..1385407adcc 100644 --- a/llvm/utils/vim/vimrc +++ b/llvm/utils/vim/vimrc @@ -10,17 +10,30 @@ " It's VIM, not VI set nocompatible -" Wrap text at 80 cols -set textwidth=80 - " A tab produces a 2-space indentation set softtabstop=2 set shiftwidth=2 set expandtab -" Highlight trailing whitespace +" Highlight trailing whitespace and lines longer than 80 columns. +highlight LongLine ctermbg=DarkYellow guibg=DarkYellow highlight WhitespaceEOL ctermbg=DarkYellow guibg=DarkYellow -match WhitespaceEOL /\s\+$/ +if v:version >= 702 + " Lines longer than 80 columns. + au BufWinEnter * let w:m0=matchadd('LongLine', '\%>80v.\+', -1) + + " Whitespace at the end of a line. This little dance suppresses + " of whitespace that has just been typed. + au BufWinEnter * let w:m1=matchadd('WhitespaceEOL', '\s\+$', -1) + au InsertEnter * call matchdelete(w:m1) + au InsertEnter * let w:m2=matchadd('WhitespaceEOL', '\s\+\%#\@80v.\+/ + au InsertEnter * syntax match WhitespaceEOL /\s\+\%#\@