blob: 586100de1561dac7b15c6db18d0516ac4bc2f5cc [file] [log] [blame]
Misha Brukman831ad842005-04-24 17:05:04 +00001" LLVM coding guidelines conformance for VIM
Misha Brukmanac7b4562009-01-02 16:26:14 +00002"
3" Maintainer: The LLVM Team, http://llvm.org
Misha Brukman831ad842005-04-24 17:05:04 +00004" WARNING: Read before you source in all these commands and macros! Some
Misha Brukmanf1ed8ed2005-05-12 21:41:48 +00005" of them may change VIM behavior that you depend on.
Misha Brukmanac7b4562009-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
Misha Brukman831ad842005-04-24 17:05:04 +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 Brukmanac7b4562009-01-02 16:26:14 +000021" Highlight trailing whitespace
22highlight WhitespaceEOL ctermbg=DarkYellow guibg=DarkYellow
23match WhitespaceEOL /\s\+$/
24
Misha Brukmanf1ed8ed2005-05-12 21:41:48 +000025" Optional
26" C/C++ programming helpers
27set autoindent
28set smartindent
29" Add and delete spaces in increments of `shiftwidth' for tabs
30set smarttab
31
Misha Brukmanac7b4562009-01-02 16:26:14 +000032" Highlight syntax in programming languages
33syntax on
34
Misha Brukman831ad842005-04-24 17:05:04 +000035" Enable filetype detection
36filetype on
37
38" LLVM Makefiles can have names such as Makefile.rules or TEST.nightly.Makefile,
39" so it's important to categorize them as such.
40augroup filetype
Misha Brukmanac7b4562009-01-02 16:26:14 +000041 au! BufRead,BufNewFile *Makefile* set filetype=make
Misha Brukman831ad842005-04-24 17:05:04 +000042augroup END
43
44" In Makefiles, don't expand tabs to spaces, since we need the actual tabs
45autocmd FileType make set noexpandtab
46
47" Useful macros for cleaning up code to conform to LLVM coding guidelines
48
49" Delete trailing whitespace and tabs at the end of each line
Misha Brukmanac7b4562009-01-02 16:26:14 +000050command! DeleteTrailingWs :%s/[\ \t]\+$//
Misha Brukman831ad842005-04-24 17:05:04 +000051
52" Convert all tab characters to two spaces
Misha Brukmanac7b4562009-01-02 16:26:14 +000053command! Untab :%s/\t/ /g