lilypond-devel
[Top][All Lists]
Advanced

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

Doc: CG update Indenting with vim section (issue 302340043 by address@hi


From: mark . opus11
Subject: Doc: CG update Indenting with vim section (issue 302340043 by address@hidden)
Date: Tue, 02 Aug 2016 02:37:05 -0700

Reviewers: ,

Description:
Doc: CG update Indenting with vim section

Suggestions for .vimrc did not produce correct indentation of C++
code, and also included personal and irrelevant settings such as
statusline and incsearch. I have replaced them with the settings
in the GNU GCC Wiki which do correctly indent. Also changed
suggested Scheme settings to use setlocal, and added a section of
settings for Texinfo files.

Please review this at https://codereview.appspot.com/302340043/

Affected files (+56, -43 lines):
  M Documentation/contributor/programming-work.itexi


Index: Documentation/contributor/programming-work.itexi
diff --git a/Documentation/contributor/programming-work.itexi b/Documentation/contributor/programming-work.itexi index 6a608f01e8009202ffc0edea84f766a20116a43e..1b887bf3b325d064a4d12845de35a7f8d2bb0df2 100644
--- a/Documentation/contributor/programming-work.itexi
+++ b/Documentation/contributor/programming-work.itexi
@@ -367,40 +367,32 @@ If you like using font-lock, you can also add this to your
 @end example


address@hidden Indenting with vim
-
-Although emacs indentation is the GNU standard, acceptable
-indentation can usually be accomplished with vim.  Some hints for
-vim are as follows:
-
-A workable .vimrc:
-
address@hidden
-set cindent
-set smartindent
-set autoindent
-set expandtab
-set softtabstop=2
-set shiftwidth=2
-filetype plugin indent on
-set incsearch
-set ignorecase smartcase
-set hlsearch
-set confirm
-set statusline=%F%m%r%h%w\ address@hidden&address@hidden %Y\ [ASCII=\%03.3b]\ [HEX=\%02.2B]\ %04l,%04v\ %p%%\ [LEN=%L]
-set laststatus=2
-set number
-" Remove trailing whitespace on write
-autocmd BufWritePre * :%s/\s\+$//e
address@hidden example
-
-With this @file{.vimrc}, files can be reindented automatically by
address@hidden Indenting with vim
+
+Although emacs indentation is the GNU standard, correct
+indentation for C++ files can be achieved by using the settings
+recommended in the
address@hidden://gcc.gnu.org/wiki/FormattingCodeForGCC, GNU GCC Wiki}.
+Save the following in @file{~/.vim/after/ftplugin/cpp.vim}:
+
address@hidden
+setlocal cindent
+setlocal cinoptions=>4,n-2,@{2,^-2,:2,=2,g0,h2,p5,t0,+2,(0,u0,w1,m1
+setlocal expandtab
+setlocal shiftwidth=2
+setlocal softtabstop=2
+setlocal textwidth=79
+setlocal fo-=ro fo+=cql
address@hidden example
+
+With these settings, files can be reindented automatically by
 highlighting the lines to be indented in visual mode (use V to
-enter visual mode) and pressing @code{=}.
+enter visual mode) and pressing @code{=}, or a single line
+correctly indented in normal mode by pressing @code{==}.

-A @file{scheme.vim} file will help improve the indentation.  This
-one was suggested by Patrick McCarty.  It should be saved in
address@hidden/.vim/after/syntax/scheme.vim}.
+A @file{scheme.vim} file will help improve the indentation of
+Scheme code.  This one was suggested by Patrick McCarty.  It
+should be saved in @file{~/.vim/after/syntax/scheme.vim}.

 @example
 " Additional Guile-specific 'forms'
@@ -417,24 +409,45 @@ syn keyword schemeSyntax define-safe-public define-music-function
 syn keyword schemeSyntax def-grace-function

 " All of the above should influence indenting too
-set lw+=define-public,define*-public
-set lw+=define*,lambda*,let-keywords*
-set lw+=defmacro,defmacro*,define-macro
-set lw+=defmacro-public,defmacro*-public
-set lw+=use-modules,define-module
-set lw+=define-method,define-class
-set lw+=define-markup-command,define-markup-list-command
-set lw+=define-safe-public,define-music-function
-set lw+=def-grace-function
+setlocal lw+=define-public,define*-public
+setlocal lw+=define*,lambda*,let-keywords*
+setlocal lw+=defmacro,defmacro*,define-macro
+setlocal lw+=defmacro-public,defmacro*-public
+setlocal lw+=use-modules,define-module
+setlocal lw+=define-method,define-class
+setlocal lw+=define-markup-command,define-markup-list-command
+setlocal lw+=define-safe-public,define-music-function
+setlocal lw+=def-grace-function

 " These forms should not influence indenting
-set lw-=if
-set lw-=set!
+setlocal lw-=if
+setlocal lw-=set!

 " Try to highlight all ly: procedures
 syn match schemeFunc "ly:[^) ]\+"
 @end example

+For documentation work on texinfo files, identify the file
+extensions used as texinfo files in your @file{.vim/filetype.vim}:
+
address@hidden
+if exists("did_load_filetypes")
+  finish
+endif
+augroup filetypedetect
+  au! BufRead,BufNewFile *.itely setfiletype texinfo
+  au! BufRead,BufNewFile *.itexi setfiletype texinfo
+  au! BufRead,BufNewFile *.tely  setfiletype texinfo
+augroup END
address@hidden example
+
+and add these settings in @file{.vim/after/ftplugin/texinfo.vim}:
+
address@hidden
+setlocal expandtab
+setlocal shiftwidth=2
+setlocal textwidth=66
address@hidden example

 @node Naming conventions
 @subsection Naming Conventions





reply via email to

[Prev in Thread] Current Thread [Next in Thread]