diff options
author | Brett Cannon <bcannon@gmail.com> | 2009-11-08 21:35:28 (GMT) |
---|---|---|
committer | Brett Cannon <bcannon@gmail.com> | 2009-11-08 21:35:28 (GMT) |
commit | 813c43ab2591f9a61c222cb62b00bb2555b690bf (patch) | |
tree | 3bd45d108e533601292629a934ab1f2d281c9009 /Misc/Vim | |
parent | 002533013f542160c294791671f3707db4491f22 (diff) | |
download | cpython-813c43ab2591f9a61c222cb62b00bb2555b690bf.zip cpython-813c43ab2591f9a61c222cb62b00bb2555b690bf.tar.gz cpython-813c43ab2591f9a61c222cb62b00bb2555b690bf.tar.bz2 |
Properly detect whether a C file is using tabs or spaces for Vim.
Closes issue #5611. Thanks Kirk McDonald and Johannes Hoff.
Diffstat (limited to 'Misc/Vim')
-rw-r--r-- | Misc/Vim/vimrc | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/Misc/Vim/vimrc b/Misc/Vim/vimrc index ae14e6a..fc00b9e 100644 --- a/Misc/Vim/vimrc +++ b/Misc/Vim/vimrc @@ -15,31 +15,29 @@ " Only basic settings needed to enforce the style guidelines are set. " Some suggested options are listed but commented out at the end of this file. - -" Number of spaces to use for an indent. -" This will affect Ctrl-T and 'autoindent'. -" Python: 4 spaces -" C: 8 spaces (pre-existing files) or 4 spaces (new files) -au BufRead,BufNewFile *.py,*pyw set shiftwidth=4 -au BufRead *.c,*.h set shiftwidth=8 -au BufNewFile *.c,*.h set shiftwidth=4 - " Number of spaces that a pre-existing tab is equal to. " For the amount of space used for a new tab use shiftwidth. -" Python: 8 -" C: 8 au BufRead,BufNewFile *py,*pyw,*.c,*.h set tabstop=8 -" Replace tabs with the equivalent number of spaces. -" Also have an autocmd for Makefiles since they require hard tabs. -" Python: yes -" C: no -" Makefile: no +" What to use for an indent. +" This will affect Ctrl-T and 'autoindent'. +" Python: 4 spaces +" C: tabs (pre-existing files) or 4 spaces (new files) +au BufRead,BufNewFile *.py,*pyw set shiftwidth=4 au BufRead,BufNewFile *.py,*.pyw set expandtab -au BufRead,BufNewFile *.c,*.h set noexpandtab +fu Select_c_style() + if search('^\t', 'n', 150) + set shiftwidth=8 + set noexpandtab + el + set shiftwidth=4 + set expandtab + en +endf +au BufRead,BufNewFile *.c,*.h call Select_c_style() au BufRead,BufNewFile Makefile* set noexpandtab -" Use the below highlight group when displaying bad whitespace is desired +" Use the below highlight group when displaying bad whitespace is desired. highlight BadWhitespace ctermbg=red guibg=red " Display tabs at the beginning of a line in Python mode as bad. |