annotate contrib/vimrc @ 136:4627f235cf2a

fix c-next example
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Thu, 08 Nov 2018 14:11:56 +0900
parents 04ced10e8804
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 " Code formatting settings for Vim.
kono
parents:
diff changeset
2 "
kono
parents:
diff changeset
3 " To enable this for GCC files by default, you can either source this file
kono
parents:
diff changeset
4 " in your .vimrc via autocmd:
kono
parents:
diff changeset
5 " :au BufNewFile,BufReadPost path/to/gcc/* :so path/to/gcc/contrib/vimrc
kono
parents:
diff changeset
6 " or source the script manually for each newly opened file:
kono
parents:
diff changeset
7 " :so contrib/vimrc
kono
parents:
diff changeset
8 " You could also use numerous plugins that enable local vimrc e.g.
kono
parents:
diff changeset
9 " mbr's localvimrc or thinca's vim-localrc (but note that the latter
kono
parents:
diff changeset
10 " is much less secure). To install local vimrc config, run
kono
parents:
diff changeset
11 " $ make vimrc
kono
parents:
diff changeset
12 " from GCC build folder.
kono
parents:
diff changeset
13 "
kono
parents:
diff changeset
14 " Copyright (C) 2014 Free Software Foundation, Inc.
kono
parents:
diff changeset
15 "
kono
parents:
diff changeset
16 " This program is free software; you can redistribute it and/or modify
kono
parents:
diff changeset
17 " it under the terms of the GNU General Public License as published by
kono
parents:
diff changeset
18 " the Free Software Foundation; either version 3 of the License, or
kono
parents:
diff changeset
19 " (at your option) any later version.
kono
parents:
diff changeset
20 "
kono
parents:
diff changeset
21 " This program is distributed in the hope that it will be useful,
kono
parents:
diff changeset
22 " but WITHOUT ANY WARRANTY; without even the implied warranty of
kono
parents:
diff changeset
23 " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
kono
parents:
diff changeset
24 " GNU General Public License for more details.
kono
parents:
diff changeset
25 "
kono
parents:
diff changeset
26 " You should have received a copy of the GNU General Public License
kono
parents:
diff changeset
27 " along with this program. If not, see <http://www.gnu.org/licenses/>.
kono
parents:
diff changeset
28
kono
parents:
diff changeset
29 function! SetStyle()
kono
parents:
diff changeset
30 let l:fname = expand("%:p")
kono
parents:
diff changeset
31 if stridx(l:fname, 'libsanitizer') != -1
kono
parents:
diff changeset
32 return
kono
parents:
diff changeset
33 endif
kono
parents:
diff changeset
34 let l:ext = fnamemodify(l:fname, ":e")
kono
parents:
diff changeset
35 let l:c_exts = ['c', 'h', 'cpp', 'cc', 'C', 'H', 'def', 'java']
kono
parents:
diff changeset
36 if index(l:c_exts, l:ext) != -1
kono
parents:
diff changeset
37 setlocal cindent
kono
parents:
diff changeset
38 setlocal tabstop=8
kono
parents:
diff changeset
39 setlocal softtabstop=2
kono
parents:
diff changeset
40 setlocal shiftwidth=2
kono
parents:
diff changeset
41 setlocal noexpandtab
kono
parents:
diff changeset
42 setlocal cinoptions=>4,n-2,{2,^-2,:2,=2,g0,f0,h2,p4,t0,+2,(0,u0,w1,m0
kono
parents:
diff changeset
43 setlocal textwidth=80
kono
parents:
diff changeset
44 setlocal formatoptions-=ro formatoptions+=cqlt
kono
parents:
diff changeset
45 endif
kono
parents:
diff changeset
46 endfunction
kono
parents:
diff changeset
47
kono
parents:
diff changeset
48 call SetStyle()