两个括号内的自动缩进-Vim

问题描述

我希望vim像这样自动缩进

int function_that_takes_long_arguments(long_argument_1,|
                                                       ^
                                              This is the cursor.

按Enter

int function_that_takes_long_arguments(long_argument_1,<enter>
>   >   >   >   >   >   >   >   >   ...|);
    ^                                ^ ^
(tab - 4 spaces)                     | |
                 (Add spaces to align) |
                      (I want the cursor to auto indent here)

开始编写其他参数

int function_that_takes_long_arguments(long_argument_1,<enter>
>   >   >   >   >   >   >   >   >   ...long_argument_2,<enter>
>   >   >   >   >   >   >   >   >   ...long_argument_3);

另一个例子:

void function(argument_1,argument_2,argument_3,<enter>
>   >   >   ..argument_4,argument_5);

解决方法

C / C ++文件的缩进通常由内部例程管理(另请参见irb(main):001:0> nil.to_i => 0 irb(main):002:0> nil&.to_i => nil )。 :h C-indenting下详细说明了受支持的选项。

因此,假设您在当前缓冲区中有:h cinoptions-values(仅包括setlocal cindent,它会自动将filetype indent on设置为一些文件类型/扩展名),那么通常就足够了

〜.vim / after / indent / c.vim

cindent

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...