2010-04-30 28 views
5

Tôi không kết thúc câu lệnh JavaScript của tôi với dấu chấm phẩy khi dòng mới sẽ hoạt động. Không có ngọn lửa, xin vui lòng. Câu hỏi của tôi là, có một gói thụt đầu dòng tự động cho vim mà sẽ làm việc?AutoIndent cho JavaScript trong Vim mà hiểu được chèn dấu chấm phẩy

Dưới đây là một ví dụ về cách câm nó là:

$(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 

Trả lời

9

Tôi hài lòng với Vim Script sau:

quả của mã của bạn sau một 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 
}) 
+0

Cảm ơn rất nhiều! Điều này thật tuyệt. http://pastebin.com/yQh2MjWP –

Các vấn đề liên quan