11debfc3dSmrg" Code formatting settings for Vim. 21debfc3dSmrg" 31debfc3dSmrg" To enable this for GCC files by default, you can either source this file 41debfc3dSmrg" in your .vimrc via autocmd: 51debfc3dSmrg" :au BufNewFile,BufReadPost path/to/gcc/* :so path/to/gcc/contrib/vimrc 61debfc3dSmrg" or source the script manually for each newly opened file: 71debfc3dSmrg" :so contrib/vimrc 81debfc3dSmrg" You could also use numerous plugins that enable local vimrc e.g. 91debfc3dSmrg" mbr's localvimrc or thinca's vim-localrc (but note that the latter 101debfc3dSmrg" is much less secure). To install local vimrc config, run 111debfc3dSmrg" $ make vimrc 121debfc3dSmrg" from GCC build folder. 131debfc3dSmrg" 141debfc3dSmrg" Copyright (C) 2014 Free Software Foundation, Inc. 151debfc3dSmrg" 161debfc3dSmrg" This program is free software; you can redistribute it and/or modify 171debfc3dSmrg" it under the terms of the GNU General Public License as published by 181debfc3dSmrg" the Free Software Foundation; either version 3 of the License, or 191debfc3dSmrg" (at your option) any later version. 201debfc3dSmrg" 211debfc3dSmrg" This program is distributed in the hope that it will be useful, 221debfc3dSmrg" but WITHOUT ANY WARRANTY; without even the implied warranty of 231debfc3dSmrg" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 241debfc3dSmrg" GNU General Public License for more details. 251debfc3dSmrg" 261debfc3dSmrg" You should have received a copy of the GNU General Public License 271debfc3dSmrg" along with this program. If not, see <http://www.gnu.org/licenses/>. 281debfc3dSmrg 291debfc3dSmrgfunction! SetStyle() 301debfc3dSmrg let l:fname = expand("%:p") 31*8feb0f0bSmrg let l:ext = fnamemodify(l:fname, ":e") 32*8feb0f0bSmrg let l:c_exts = ['c', 'h', 'cpp', 'cc', 'C', 'H', 'def', 'java'] 331debfc3dSmrg if stridx(l:fname, 'libsanitizer') != -1 341debfc3dSmrg return 351debfc3dSmrg endif 36*8feb0f0bSmrg if l:ext != "py" 371debfc3dSmrg setlocal tabstop=8 381debfc3dSmrg setlocal softtabstop=2 391debfc3dSmrg setlocal shiftwidth=2 401debfc3dSmrg setlocal noexpandtab 41*8feb0f0bSmrg endif 421debfc3dSmrg setlocal textwidth=80 431debfc3dSmrg setlocal formatoptions-=ro formatoptions+=cqlt 44*8feb0f0bSmrg if index(l:c_exts, l:ext) != -1 45*8feb0f0bSmrg setlocal cindent 46*8feb0f0bSmrg setlocal cinoptions=>4,n-2,{2,^-2,:2,=2,g0,f0,h2,p4,t0,+2,(0,u0,w1,m0 471debfc3dSmrg endif 481debfc3dSmrgendfunction 491debfc3dSmrg 501debfc3dSmrgcall SetStyle() 51