1 " LLVM coding guidelines conformance for VIM
3 " Maintainer: The LLVM Team, http://llvm.org
4 " WARNING: Read before you source in all these commands and macros! Some
5 " of them may change VIM behavior that you depend on.
7 " You can run VIM with these settings without changing your current setup with:
8 " $ vim -u /path/to/llvm/utils/vim/vimrc
13 " A tab produces a 2-space indentation
18 " Highlight trailing whitespace and lines longer than 80 columns.
19 highlight LongLine ctermbg=DarkYellow guibg=DarkYellow
20 highlight WhitespaceEOL ctermbg=DarkYellow guibg=DarkYellow
22 " Lines longer than 80 columns.
23 au BufWinEnter * let w:m0=matchadd('LongLine', '\%>80v.\+', -1)
25 " Whitespace at the end of a line. This little dance suppresses
26 " of whitespace that has just been typed.
27 au BufWinEnter * let w:m1=matchadd('WhitespaceEOL', '\s\+$', -1)
28 au InsertEnter * call matchdelete(w:m1)
29 au InsertEnter * let w:m2=matchadd('WhitespaceEOL', '\s\+\%#\@<!$', -1)
30 au InsertLeave * call matchdelete(w:m2)
31 au InsertLeave * let w:m1=matchadd('WhitespaceEOL', '\s\+$', -1)
33 au BufRead,BufNewFile * syntax match LongLine /\%>80v.\+/
34 au InsertEnter * syntax match WhitespaceEOL /\s\+\%#\@<!$/
35 au InsertLeave * syntax match WhitespaceEOL /\s\+$/
38 " Enable filetype detection
42 " C/C++ programming helpers
45 autocmd FileType * set nocindent smartindent
46 autocmd FileType c,cpp set cindent
48 " Set a few indentation parameters. See the VIM help for cinoptions-values for
49 " details. These aren't absolute rules; they're just an approximation of
50 " common style in LLVM source.
51 set cinoptions=:0,g0,(0,Ws,l1
52 " Add and delete spaces in increments of `shiftwidth' for tabs
55 " Highlight syntax in programming languages
58 " LLVM Makefiles can have names such as Makefile.rules or TEST.nightly.Makefile,
59 " so it's important to categorize them as such.
61 au! BufRead,BufNewFile *Makefile* set filetype=make
64 " In Makefiles, don't expand tabs to spaces, since we need the actual tabs
65 autocmd FileType make set noexpandtab
67 " Useful macros for cleaning up code to conform to LLVM coding guidelines
69 " Delete trailing whitespace and tabs at the end of each line
70 command! DeleteTrailingWs :%s/\s\+$//
72 " Convert all tab characters to two spaces
73 command! Untab :%s/\t/ /g
75 " Enable syntax highlighting for LLVM files. To use, copy
76 " utils/vim/llvm.vim to ~/.vim/syntax .
78 au! BufRead,BufNewFile *.ll set filetype=llvm
81 " Enable syntax highlighting for tablegen files. To use, copy
82 " utils/vim/tablegen.vim to ~/.vim/syntax .
84 au! BufRead,BufNewFile *.td set filetype=tablegen
87 " Additional vim features to optionally uncomment.