gpt4 book ai didi

javascript - Vim 中 JavaScript 的 AutoIndent 可以理解分号插入

转载 作者:数据小太阳 更新时间:2023-10-29 05:59:33 33 4
gpt4 key购买 nike

当换行符起作用时,我不会以分号结束我的 JavaScript 语句。没有火焰,请。我的问题是,是否有适用于 vim 的自动缩进包可以使用?

这是一个多么愚蠢的例子:

$(function(){
var foo // code starts here,
// The following line breaks things, but adding a comment to it fixes things
({a:1})
var foo // everything is stuck left now.
({a:1})
var foo // previous line justifies all following lines wherever you put it

function flat(){
var foo // function starts out right, but the next line dedents it
({a:1})
var foo
}
var foo // now we're over here
if (foo) {
var foo // this if block doesn't close properly
} else if (foo){ // add a comment here to dedent the else body
var foo
} else if (foo){
var foo
} // add a comment here to indent and break the following lines
var foo
})
// all parenthesis match, but yet our indentations don't

最佳答案

我对以下 Vim 脚本很满意:

gg=G 之后的代码结果:

var one = 1
var two = 2
var fun = function(){
var three = 3
var four = 4
var five = 5
}

var fun2 = (function(foo){
var six = 6
})

关于javascript - Vim 中 JavaScript 的 AutoIndent 可以理解分号插入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2742441/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com