]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
doc: add a vim indentation example
authorIvan Sichmann Freitas <ivansichfreitas@gmail.com>
Tue, 19 Jul 2011 02:43:19 +0000 (23:43 -0300)
committerPádraig Brady <P@draigBrady.com>
Wed, 27 Jul 2011 12:51:15 +0000 (13:51 +0100)
HACKING: add a vim example showing how to configure it to follow GNU
indentation in coreutils source files.

HACKING

diff --git a/HACKING b/HACKING
index 8933e9a744de1f3cdecd150d39d09d47537b74b1..51c4acdc8a035c80d6999c00bf84e901f0791f57 100644 (file)
--- 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