summaryrefslogtreecommitdiffstats
path: root/Misc/Vim
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2009-11-08 21:41:27 (GMT)
committerBrett Cannon <bcannon@gmail.com>2009-11-08 21:41:27 (GMT)
commit92634d6b3497ba4f5ab0a1f7ed7995a27612654e (patch)
treefff7cc66b2c170a3e0699dfb0ccfbe5d6c702ab4 /Misc/Vim
parentca13a0dc096fe95a3d92195ea5533dc813785645 (diff)
downloadcpython-92634d6b3497ba4f5ab0a1f7ed7995a27612654e.zip
cpython-92634d6b3497ba4f5ab0a1f7ed7995a27612654e.tar.gz
cpython-92634d6b3497ba4f5ab0a1f7ed7995a27612654e.tar.bz2
Blocked revisions 76154 via svnmerge
........ r76154 | brett.cannon | 2009-11-08 13:35:28 -0800 (Sun, 08 Nov 2009) | 4 lines 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/vimrc37
1 files changed, 17 insertions, 20 deletions
diff --git a/Misc/Vim/vimrc b/Misc/Vim/vimrc
index 2013bf3..fc00b9e 100644
--- a/Misc/Vim/vimrc
+++ b/Misc/Vim/vimrc
@@ -15,35 +15,32 @@
" 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: 4 spaces
-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: yes
-" Makefile: no
-au BufRead,BufNewFile *.py,*.pyw,*.c,*.h set expandtab
+" 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
+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.
-" Should be done for C code, but not until all code has been moved to 4-space
-" indents.
au BufRead,BufNewFile *.py,*.pyw match BadWhitespace /^\t\+/
" Make trailing whitespace be flagged as bad.
au BufRead,BufNewFile *.py,*.pyw,*.c,*.h match BadWhitespace /\s\+$/