我正在使用Vim-R-plugin和Vim来为我的R代码提供语法突出显示。规则缩进样式在圆括号的开头对齐函数中的参数。我想将其更改为更像花括号内的代码,其中新行缩进两个空格,而不是内联大括号。
我的函数名往往很冗长,默认的缩进样式会让我的所有参数一直推到屏幕的右边。
下面是一些示例:
# Default indentation style
result <- fun(
par1 = "abc",
par2 = "def",
par3 = 3
)所需的样式模仿for循环和函数定义的缩进样式。
# Desired indentation style
result <- fun(
par1 = "abc",
par2 = "def",
par3 = 3
)
# Similar to for loop indentation
for(i in 1:10) {
print(i)
}
# ... and function definitions
fun <- function(par1 = 1) {
print(par1 + 1)
}我看了Vim-R-plugin的代码,但它太密集了,我无法理解。有没有办法让我改变它?
发布于 2014-06-17 17:18:21
如果有人想问这个问题:
:help r-plugin-indenting简短的回答。在.vimrc中,添加以下行:
" set vim-r-plugin to
let r_indent_align_args = 0
" Set vim-r-plugin to mimics ess :
let r_indent_ess_comments = 0
let r_indent_ess_compatible = 0缩进将如OP所描述的那样。
发布于 2013-04-11 03:48:38
首先看一下:help 'cindent'和:help 'smartindent';您可以使用这两个选项中的任何一个相对容易地配置缩进。您也可以尝试编写自己的indentexpr,但这有点高级。这将需要抛弃Vim-R插件,转而使用Vim原生缩进解决方案。
https://stackoverflow.com/questions/13597256
复制相似问题