Misha Brukman | 3d6eea5 | 2005-04-24 17:05:04 +0000 | [diff] [blame] | 1 | " LLVM coding guidelines conformance for VIM |
Misha Brukman | adf4e4d | 2009-01-02 16:26:14 +0000 | [diff] [blame] | 2 | " |
| 3 | " Maintainer: The LLVM Team, http://llvm.org |
Misha Brukman | 3d6eea5 | 2005-04-24 17:05:04 +0000 | [diff] [blame] | 4 | " WARNING: Read before you source in all these commands and macros! Some |
Misha Brukman | 2bb5508 | 2005-05-12 21:41:48 +0000 | [diff] [blame] | 5 | " of them may change VIM behavior that you depend on. |
Misha Brukman | adf4e4d | 2009-01-02 16:26:14 +0000 | [diff] [blame] | 6 | " |
| 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 |
| 11 | set nocompatible |
Misha Brukman | 3d6eea5 | 2005-04-24 17:05:04 +0000 | [diff] [blame] | 12 | |
| 13 | " Wrap text at 80 cols |
| 14 | set textwidth=80 |
| 15 | |
| 16 | " A tab produces a 2-space indentation |
Dan Gohman | f225d2e | 2009-01-04 00:05:43 +0000 | [diff] [blame] | 17 | set softtabstop=2 |
Misha Brukman | 3d6eea5 | 2005-04-24 17:05:04 +0000 | [diff] [blame] | 18 | set shiftwidth=2 |
| 19 | set expandtab |
| 20 | |
Misha Brukman | adf4e4d | 2009-01-02 16:26:14 +0000 | [diff] [blame] | 21 | " Highlight trailing whitespace |
| 22 | highlight WhitespaceEOL ctermbg=DarkYellow guibg=DarkYellow |
| 23 | match WhitespaceEOL /\s\+$/ |
| 24 | |
Misha Brukman | 2bb5508 | 2005-05-12 21:41:48 +0000 | [diff] [blame] | 25 | " Optional |
| 26 | " C/C++ programming helpers |
Dan Gohman | 96eafe2 | 2009-01-04 00:03:54 +0000 | [diff] [blame] | 27 | set cindent |
| 28 | " Don't indent switch case labels beyond the switch. |
| 29 | set cinoptions=:0 |
Misha Brukman | 2bb5508 | 2005-05-12 21:41:48 +0000 | [diff] [blame] | 30 | " Add and delete spaces in increments of `shiftwidth' for tabs |
| 31 | set smarttab |
| 32 | |
Misha Brukman | adf4e4d | 2009-01-02 16:26:14 +0000 | [diff] [blame] | 33 | " Highlight syntax in programming languages |
| 34 | syntax on |
| 35 | |
Misha Brukman | 3d6eea5 | 2005-04-24 17:05:04 +0000 | [diff] [blame] | 36 | " Enable filetype detection |
| 37 | filetype 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. |
| 41 | augroup filetype |
Misha Brukman | adf4e4d | 2009-01-02 16:26:14 +0000 | [diff] [blame] | 42 | au! BufRead,BufNewFile *Makefile* set filetype=make |
Misha Brukman | 3d6eea5 | 2005-04-24 17:05:04 +0000 | [diff] [blame] | 43 | augroup END |
| 44 | |
| 45 | " In Makefiles, don't expand tabs to spaces, since we need the actual tabs |
| 46 | autocmd 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 Brukman | adf4e4d | 2009-01-02 16:26:14 +0000 | [diff] [blame] | 51 | command! DeleteTrailingWs :%s/[\ \t]\+$// |
Misha Brukman | 3d6eea5 | 2005-04-24 17:05:04 +0000 | [diff] [blame] | 52 | |
| 53 | " Convert all tab characters to two spaces |
Misha Brukman | adf4e4d | 2009-01-02 16:26:14 +0000 | [diff] [blame] | 54 | command! Untab :%s/\t/ /g |