簡體   English   中英

Vim中的AutoIndent for JavaScript,了解Semicolon Insertion

[英]AutoIndent for JavaScript in Vim that understands Semicolon Insertion

當換行符起作用時,我不會以分號結束我的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
})

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM