Vim 对于带有 lapply 的匿名 R 函数自动缩进太远

Vim autoindents too far for anonymous R function with lapply

Vim 以下 R 代码的自动缩进太远(超过 4 个空格):

lapply(1:10, function(x){
       Something here
})

我该如何解决这个问题?

这是一张图片:

这是一个最小的 .vimrc,它在编辑带有 .R 扩展名的文件时复制了这种行为:

filetype on
filetype plugin on
filetype indent on
set ts=4 sw=4 

只需使用 .vimrc 选项 shiftwidth (2 个空格):

set shiftwidth=2

来源: http://vimdoc.sourceforge.net/htmldoc/options.html#'shiftwidth'

我找到了解决方案:

正在添加

let r_indent_align_args = 0

我的 .vimrc 解决了这个问题。有关详细信息,请参阅 :h ft-r-indent。