[gimp] devel-docs: c.vim to help contributors enforce our coding style in VIM.



commit cc02ee1160bf0c6c6ba10122c93f63f9feaafeab
Author: Jehan <jehan girinstud io>
Date:   Tue Aug 23 17:28:31 2016 +0200

    devel-docs: c.vim to help contributors enforce our coding style in VIM.
    
    The GNU coding standards rules can be found in:
    https://gcc.gnu.org/wiki/FormattingCodeForGCC
    I added a few rules, like if the file has existing tabs, we want to show
    them as 8 columns. Yet typing tabs automatically expands to 2 spaces.
    
    I also added a rule to highlight (in red) trailing whitespaces, but also
    tabs (everywhere, not only trailing) making them easy to spot.
    This file can be easily sourced from vimrc for the whole GIMP tree, but
    I advise against setting VIM to automatic discover a locale .vimrc,
    which is possible but a high security risk since a third-party vimrc
    could contain random shell commands.

 devel-docs/c.vim |   28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)
---
diff --git a/devel-docs/c.vim b/devel-docs/c.vim
new file mode 100644
index 0000000..15aed01
--- /dev/null
+++ b/devel-docs/c.vim
@@ -0,0 +1,28 @@
+" GIMP coding style for vim "
+
+" To enable these vim rules for GIMP only, add this command to your vimrc:
+" autocmd BufNewFile,BufRead /path/to/gimp/*.[ch] source /path/to/gimp/devel-docs/c.vim
+"
+" Do not use `set exrc` which is a security risk for your system since vim may
+" be tricked into running shell commands by .vimrc files hidden in malicious
+" projects (`set secure` won't protect you since it is not taken into account
+" if the files are owned by you).
+
+" GNU style
+setlocal cindent
+setlocal cinoptions=>4,n-2,{2,^-2,:2,=2,g0,h2,p5,t0,+2,(0,u0,w1,m1
+setlocal shiftwidth=2
+setlocal softtabstop=2
+setlocal textwidth=79
+setlocal fo-=ro fo+=cql
+
+" Tabs are always inserted as spaces.
+set expandtab
+" But if there are tabs already, show them as 8 columns.
+setlocal tabstop=8
+
+" Highlight in red trailing whitespaces and tabs everywhere.
+highlight TrailingWhitespace ctermbg=LightRed guibg=LightRed
+match TrailingWhitespace /\s\+$/
+highlight ForbiddenTabs ctermbg=DarkRed guibg=DarkRed
+2match ForbiddenTabs /\t/


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]