summaryrefslogtreecommitdiff
path: root/utils/vim
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2010-02-26 21:24:46 +0000
committerDan Gohman <gohman@apple.com>2010-02-26 21:24:46 +0000
commitd30103dd364cc9f5b6d69b91ed75b932feeab90d (patch)
treed4ebde7cd32fcb5f69bc8da49c140b08bb4e6e9a /utils/vim
parentbb134231d85060c2d0d11c861405d4376dc5fcea (diff)
downloadllvm-d30103dd364cc9f5b6d69b91ed75b932feeab90d.tar.gz
llvm-d30103dd364cc9f5b6d69b91ed75b932feeab90d.tar.bz2
llvm-d30103dd364cc9f5b6d69b91ed75b932feeab90d.tar.xz
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97267 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/vim')
-rw-r--r--utils/vim/vimrc30
1 files changed, 25 insertions, 5 deletions
diff --git a/utils/vim/vimrc b/utils/vim/vimrc
index 4909f602cf..1385407adc 100644
--- a/utils/vim/vimrc
+++ b/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\+\%#\@<!$', -1)
+ au InsertLeave * call matchdelete(w:m2)
+ au InsertLeave * let w:m1=matchadd('WhitespaceEOL', '\s\+$', -1)
+else
+ au BufRead,BufNewFile * syntax match LongLine /\%>80v.\+/
+ au InsertEnter * syntax match WhitespaceEOL /\s\+\%#\@<!$/
+ au InsertLeave * syntax match WhitespaceEOL /\s\+$/
+endif
" Enable filetype detection
filetype on
@@ -70,3 +83,10 @@ augroup END
augroup filetype
au! BufRead,BufNewFile *.td set filetype=tablegen
augroup END
+
+" Additional vim features to optionally uncomment.
+"set showcmd
+"set showmatch
+"set showmode
+"set incsearch
+"set ruler