在vim中格式化多行语句
像这样的长语句
if ( (image == null) || (image.getFileHash() == null) || (image.getFileImage() == null) )
在vim中,当我在第二个之前按下回车键时,
if ( (image == null) || (image.getFileHash() == null)
|| (image.getFileImage() == null) ) {
会像这样缩进,或者有没有办法设置vim缩进它,例如
if ( (image == null) || (image.getFileHash() == null)
|| (image.getFileImage() == null) ) {
,将其与上第一行的(之后的列对齐。
用dash-tom- bang的帮助下解决了一部分 问题。但是,现在大括号没有按预期对齐 if {
在同一行开始。
if ( (image == null) || (image.getFileHash() == null) ||
(image.getFileImage() == null) )
{
}
if ( (image == null) || (image.getFileHash() == null) ||
(image.getFileImage() == null) ) {
}
In vim a long statements like
if ( (image == null) || (image.getFileHash() == null) || (image.getFileImage() == null) )
gets indented like this when I hit an enter before the second OR
if ( (image == null) || (image.getFileHash() == null)
|| (image.getFileImage() == null) ) {
is there a way to set vim to indent it like
if ( (image == null) || (image.getFileHash() == null)
|| (image.getFileImage() == null) ) {
i.e., aligning it with the column after ( of the first previous line.
With dash-tom-bang's help was able to solve a part of the
problem. However, now the curly brackets are not aligned as expected
if {
starts on the same line.
if ( (image == null) || (image.getFileHash() == null) ||
(image.getFileImage() == null) )
{
}
if ( (image == null) || (image.getFileHash() == null) ||
(image.getFileImage() == null) ) {
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
控制这一点的设置是
cinoptions
,请参阅:help cinoptions-values
。将其添加到您的 .vimrc 以与最本地的未闭括号对齐。 (您可以通过给出不同的数字(包括负数)来在空格中提供额外的缩进。您可以使用 Ns 缩进 N 个制表位。)
默认值为 2s,这将在打开的括号后缩进两个制表符;希望这就是您所看到的。 :)
The setting that controls this is
cinoptions
, see:help cinoptions-values
.Add this to your .vimrc to align with the most local unclosed parenthesis. (You can give extra indent in spaces by giving a different number, including negatives. You can indent N tabstops by using Ns.)
The default value is 2s, which would indent two tabs past the open paren; hopefully this is what you're seeing. :)