blob: c400a13c187d55f344b16acd921be248f97448bc [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001" LLVM coding guidelines conformance for VIM
Misha Brukmanb701a472009-01-02 16:26:14 +00002"
3" Maintainer: The LLVM Team, http://llvm.org
Dan Gohmanf17a25c2007-07-18 16:29:46 +00004" WARNING: Read before you source in all these commands and macros! Some
5" of them may change VIM behavior that you depend on.
Misha Brukmanb701a472009-01-02 16:26:14 +00006"
7" You can run VIM with these settings without changing your current setup with:
8" $ vim -u /path/to/llvm/utils/vim/vimrc
9
10" It's VIM, not VI
11set nocompatible
Dan Gohmanf17a25c2007-07-18 16:29:46 +000012
13" Wrap text at 80 cols
14set textwidth=80
15
16" A tab produces a 2-space indentation
17set tabstop=2
18set shiftwidth=2
19set expandtab
20
Misha Brukmanb701a472009-01-02 16:26:14 +000021" Highlight trailing whitespace
22highlight WhitespaceEOL ctermbg=DarkYellow guibg=DarkYellow
23match WhitespaceEOL /\s\+$/
24
Dan Gohmanf17a25c2007-07-18 16:29:46 +000025" Optional
26" C/C++ programming helpers
Dan Gohman5adb6032009-01-04 00:03:54 +000027set cindent
28" Don't indent switch case labels beyond the switch.
29set cinoptions=:0
Dan Gohmanf17a25c2007-07-18 16:29:46 +000030" Add and delete spaces in increments of `shiftwidth' for tabs
31set smarttab
32
Misha Brukmanb701a472009-01-02 16:26:14 +000033" Highlight syntax in programming languages
34syntax on
35
Dan Gohmanf17a25c2007-07-18 16:29:46 +000036" Enable filetype detection
37filetype on
38
39" LLVM Makefiles can have names such as Makefile.rules or TEST.nightly.Makefile,
40" so it's important to categorize them as such.
41augroup filetype
Misha Brukmanb701a472009-01-02 16:26:14 +000042 au! BufRead,BufNewFile *Makefile* set filetype=make
Dan Gohmanf17a25c2007-07-18 16:29:46 +000043augroup END
44
45" In Makefiles, don't expand tabs to spaces, since we need the actual tabs
46autocmd FileType make set noexpandtab
47
48" Useful macros for cleaning up code to conform to LLVM coding guidelines
49
50" Delete trailing whitespace and tabs at the end of each line
Misha Brukmanb701a472009-01-02 16:26:14 +000051command! DeleteTrailingWs :%s/[\ \t]\+$//
Dan Gohmanf17a25c2007-07-18 16:29:46 +000052
53" Convert all tab characters to two spaces
Misha Brukmanb701a472009-01-02 16:26:14 +000054command! Untab :%s/\t/ /g