Drop all 'Latest Change' leftover references in several config files
[grml-etc-core.git] / etc / skel / .vim / ftplugin / c.vim
1 " Filename:      c.vim
2 " Purpose:       configuration file for c programming with Vim
3 " Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>, Bart Trojanowski <bart@jukie.net>
4 " Bug-Reports:   see http://grml.org/bugs/
5 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
6 " This file is heavily based on Bart's blog entry
7 " "vim and linux CodingStyle" => http://jukie.net/~bart/blog/20070209172606
8
9 " some general options
10   set noexpandtab                  " use tabse, not spaces
11   set tabstop=8                    " tabstops of 8
12   set shiftwidth=8                 " indents of 8
13   set textwidth=78                 " screen in 80 columns wide, wrap at 78
14   set autoindent smartindent       " turn on auto/smart indenting
15   set smarttab                     " make <tab> and <backspace> smarter
16   set backspace=eol,start,indent   " allow backspacing over indent, eol, & start
17   set foldmethod=syntax            " syntax highlighting items specify folds
18
19 " keybindings
20   nmap <C-J> vip=                  " forces (re)indentation of a block of code
21 "  imap if(      if () {<cr>}<esc>k$2hi
22 "  imap ife(     <ESC>:call IfElse()<CR>a
23 "  imap while(   while () {<cr>}<esc>k$2hi
24 "  imap switch(  switch () {<cr>default:<cr>break;<cr>}<esc>3k$2hi
25 "  imap do{      <ESC>:call DoWhile()<CR>a
26 "  imap for(     for (;;) {<cr>}<esc>k$3hi
27
28 " Edit compile speedup (hotkeys)
29 " --------- start info -----------------
30 " F2 - update file without confirmation
31 " F3 - file open dialog
32 " F5 - calls manual of function
33 " F6 - list all errors
34 " F7 - display previous error
35 " F8 - display next error
36 " --------- end info -------------------
37   map <F2>  :update<CR>
38   map <F3>  :browse confirm e<CR>
39   map <F5>  <Esc>:! man <cfile> <CR>
40   map <F6>  :copen<CR>
41   map <F7>  :cp<CR>
42   map <F8>  :cn<CR>
43
44 " abbreviations...
45   abb #i #include
46   abb #d #define
47   abb #f #ifdef
48   abb #n #endif
49 "  iab ,I if()<CR>{<CR>}<ESC>kk$i
50 "  iab ,F for(;;)<CR>{<CR>}<ESC>kk$hhi
51 "  iab ,E else<CR>{<CR>}<ESC>O
52
53 " syntax highlighting
54   syntax on
55   syn keyword cType uint ubyte ulong uint64_t uint32_t uint16_t uint8_t boolean_t int64_t int32_t int16_t int8_t u_int64_t u_int32_t u_int16_t u_int8_t
56   syn keyword cOperator likely unlikely
57   syn match ErrorLeadSpace /^ \+/         " highlight any leading spaces
58   syn match ErrorTailSpace / \+$/         " highlight any trailing spaces
59
60 " C-mode formatting options
61 "   t auto-wrap comment
62 "   c allows textwidth to work on comments
63 "   q allows use of gq* for auto formatting
64 "   l don't break long lines in insert mode
65 "   r insert '*' on <cr>
66 "   o insert '*' on newline with 'o'
67 "   n recognize numbered lists
68   set formatoptions=tcqlron
69
70 " C-mode options (cinoptions==cino)
71 " N     number of spaces
72 " Ns    number of spaces * shiftwidth
73 " >N    default indent
74 " eN    extra indent if the { is at the end of a line
75 " nN    extra indent if there is no {} block
76 " fN    indent of the { of a function block
77 " gN    indent of the C++ class scope declarations (public, private, protected)
78 " {N    indent of a { on a new line after an if,while,for...
79 " }N    indent of a } in reference to a {
80 " ^N    extra indent inside a function {}
81 " :N    indent of case labels
82 " =N    indent of case body
83 " lN    align case {} on the case line
84 " tN    indent of function return type
85 " +N    indent continued algibreic expressions
86 " cN    indent of comment line after /*
87 " )N    vim searches for closing )'s at most N lines away
88 " *N    vim searches for closing */ at most N lines away
89   set cinoptions=:0l1t0g0
90
91 " folding
92 "  - reserve 4 columns on the left for folding tree
93 "  - fold by syntax, use {}'s
94 "  - start with all folds open
95   if winwidth(0) > 80
96     set foldcolumn=4
97   endif
98
99 " EOF