star-style

Writing conventions for co-authors
git clone git://git.meso-star.com/star-style.git
Log | Files | Refs | README | LICENSE

vimrc (4121B)


      1 " Copyright (C) 2026 |Méso|Star> (contact@meso-star.com)
      2 " Copyright (C) 2023-2025 Vincent Forest (vaplv@posteo.net)
      3 "
      4 " Copying and distribution of this file, with or without modification,
      5 " are permitted in any medium without royalty provided the copyright
      6 " notice and this notice are preserved. This file is offered as-is,
      7 " without any warranty.
      8 
      9 syntax on " Enable syntax  highlighting
     10 
     11 set nocompatible " Do not use Vim just like Vi but allow Vim features
     12 
     13 set autoindent " Copy indent from current line when starting a new line
     14 set backup " Keep a copy of the origin file while writing to an existing file
     15 set mouse= " Disable the use of the mouse in all modes
     16 set nohls " Do not highlight all the matches of a search pattern
     17 set number " Print the line number in front of each line
     18 set nofoldenable " Disable folding
     19 set textwidth=72 " Maximum width of text that is being inserted
     20 
     21 " Characters to display in list mode (set [no]list),
     22 " i.e. display hidden characters
     23 set listchars=eol:$,nbsp:_
     24 
     25 " How Backspace, Del, CTRL-W and CTRL-U work in Insert mode
     26 set backspace=indent,eol,start
     27 
     28 " Set 'formatoptions' to break comment lines (c) but not other lines
     29 " (t). Insert the comment leader (r) when hitting <CR> or using "o" (o).
     30 " Allow formatting of comments with "gq" (q). Do not automatically
     31 " format long lones (l), i.e., the ones that exceed 'textwidth'.
     32 set fo-=t fo+=croql
     33 
     34 filetype plugin on " Load the plugin files for specific file types
     35 
     36 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
     37 " Formatting and indentation of C sources
     38 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
     39 " Setup C indentation rules:
     40 "   +2: indent a continuation line inside a function 2 additional characters
     41 "   t0: Indent of a function return type declaration 0 characters
     42 "       from the margin
     43 "   (0: in unclosed parentheses, indent 0 characters from the line with the
     44 "       unclosed parenthesis
     45 "   u0: same as (0 but for one nesting level deeper.
     46 set cino=+2,t0,(0,u0
     47 
     48 " Define as C the filetype of *.h and *.c files.
     49 " Otherwise, *.h files were defined as C++ files.
     50 au BufNewFile,BufRead *.h,*.c set filetype=c
     51 
     52 au FileType c setlocal tabstop=8 " Number of spaces that a <Tab> in the file counts for
     53 au FileType c setlocal softtabstop=2 " Number of spaces that a <Tab> counts for while editing
     54 au FileType c setlocal shiftwidth=2 " Number of spaces to use for each step of (auto)indent
     55 au FileType c setlocal expandtab " In insert mode, replace <Tab>s by spaces
     56 
     57 au FileType c setlocal cindent " Set the cindent option for C files
     58 au FileType c setlocal textwidth=80 " Set text width for C files
     59 
     60 " Setup C comments format rules:
     61 "   "sO:*\ -"
     62 "       Start (s) a comment that is not treated as a normal comment by
     63 "       the o (O) command that insert a new line.
     64 "       It actually starts the comment of a list item (see below).
     65 "   "mO:*\ \ "
     66 "       Add two spaces (\ \ ) after the C comment character (*) when
     67 "       adding a new line (O) in the middle (m) of a list item comment
     68 "       (see above).
     69 "   "exO:*/"
     70 "       End (e) a three piece C comment by typing the last end-comment
     71 "       character (/), as the first action on a new line commenting a
     72 "       list item (x) (see above), i.e. automatically ignore the 2
     73 "       spaces following the '*' character.
     74 "   "s1:/*"
     75 "       Start (s) a three piece C comment (/*).
     76 "       Automatically adds a space offset (1) to the middle or end of
     77 "       the comment leader.
     78 "   "mb:*"
     79 "       Middle (m) of three piece C comment (*).
     80 "       Add a blank (b) after the comment string (*).
     81 "       This avoid to recognize a pointer indirection as a comment.
     82 "   "ex:*/"
     83 "       End (e) of three piece C comment (*/).
     84 "       Allow to close the comment by typing the last char of
     85 "       end-comment (i.e. '/') as the first action on a new
     86 "       middle-comment line (x), i.e. automatically discard the blank
     87 "       following the '*' char.
     88 "   ":///"
     89 "   "://"
     90 "       Continue comments in C99 format on the following lines.
     91 au Filetype c setlocal comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,:///,://