[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] HACKING: add a vim indentation example
From: |
ivansichfreitas |
Subject: |
[PATCH] HACKING: add a vim indentation example |
Date: |
Tue, 19 Jul 2011 00:18:59 -0300 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
From baa5d25da96fb10fcbde352216cc15e0ab0ced15 Mon Sep 17 00:00:00 2001
From: Ivan Sichmann Freitas <address@hidden>
Date: Mon, 18 Jul 2011 23:43:19 -0300
Subject: [PATCH] HACKING: add a vim indentation example.
HACKING: add a vim example showing how to configure it to follow GNU
indentation in coreutils source files.
---
HACKING | 21 ++++++++++++++++++---
1 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/HACKING b/HACKING
index 8933e9a..51c4acd 100644
--- a/HACKING
+++ b/HACKING
@@ -349,10 +349,25 @@ this code enables the right mode:
(not (string-equal mode-name "Makefile")))
(setq indent-tabs-mode nil))))
-[*] Makefile and ChangeLog files are exempt, of course.
+If you use vim (7+ compiled with autocommands), and coreutils working
+directory name also matches, add the following in ~/.vimrc:
+
+ " Set GNU style indentation, spaces instead of TABs
+ function! CoreutilsIndent()
+ " Check if 'coreutils' is part of the current working directory
+ if match(getcwd(), "coreutils") > 0
+ " The next 3 lines below set the GNU indentation
+ setlocal cinoptions=>4,n-2,{2,^-2,:2,=2,g0,h2,p5,t0,+2,(0,u0,w1,m1
+ setlocal shiftwidth=2
+ setlocal tabstop=8
+ " Coreutils specific, expand TABs with spaces
+ setlocal expandtab
+ endif
+ endfunction
+
+ autocmd BufEnter *.c,*.h call CoreutilsIndent()
-[FIXME: suggest vim syntax to do same thing, if it can be done safely.
- Most distros now "set nomodeline" by default for a good reason. ]
+[*] Makefile and ChangeLog files are exempt, of course.
Send patches to the address listed in --help output
--
1.7.6
pgp9qvEVqq08Y.pgp
Description: PGP signature
- [PATCH] HACKING: add a vim indentation example,
ivansichfreitas <=