Hi Bram, My Vim-R-plugin (#2628) includes a script to indent R code. I improved the script on February, 2011 and since then only one bug was reported (and fixed). So I believe that the script is mature enough to be considered for inclusion in Vim runtime directory.
One remaining problem of the script is that it is slow. The indentation algorithm sometimes slowly goes backwards looking for an opening parenthesis or brace or for the beginning of a "for", "if" or "while" statement. This is necessary because the indentation level of a given line depends on the indentation level of the previous one, but the previous line is not always the line above. It's the line where the statement immediately above started. The indent/r.vim script is attached. I also attached a patch to doc/indent.txt. Best regards, Jakson Aquino -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php
r.vim
Description: Binary data
diff -r ba9f075a347d runtime/doc/indent.txt
--- a/runtime/doc/indent.txt Sun Aug 28 16:02:28 2011 +0200
+++ b/runtime/doc/indent.txt Wed Aug 31 00:25:26 2011 -0300
@@ -706,6 +706,43 @@
let g:pyindent_continue = '&sw * 2'
+R *ft-r-indent*
+
+Function arguments are aligned if they span for multiple lines. If you prefer
+do not have the arguments of functions aligned, put in your |vimrc|:
+>
+ let r_indent_align_args = 0
+<
+All lines beginning with a comment character, #, get the same indentation
+level of the normal R code. Users of Emacs/ESS may be used to have lines
+beginning with a single # indented in the 40th column, ## indented as R code,
+and ### not indented. If you prefer that lines beginning with comment
+characters are aligned as they are by Emacs/ESS, put in your |vimrc|:
+>
+ let r_indent_ess_comments = 1
+<
+If you prefer that lines beginning with a single # are aligned at a column
+different from the 40th one, you should set a new value to the variable
+r_indent_comment_column, as in the example below:
+>
+ let r_indent_comment_column = 30
+<
+Any code after a line that ends with "<-" is indented. Emacs/ESS does not
+indent the code if it is a top level function. If you prefer that the
+Vim-R-plugin behaves like Emacs/ESS in this regard, put in your |vimrc|:
+>
+ let r_indent_ess_compatible = 1
+<
+Below is an example of indentation with and without this option enabled:
+>
+ ### r_indent_ess_compatible = 1 ### r_indent_ess_compatible = 0
+ foo <- foo <-
+ function(x) function(x)
+ { {
+ paste(x) paste(x)
+ } }
+<
+
SHELL *ft-sh-indent*
The amount of indent applied under various circumstances in a shell file can
