2008-09-18 11 views
13

के साथ फ़ंक्शन पैरामीटर सूचियों को अस्तर करना एकाधिक लाइनों के विस्तार के लिए पर्याप्त तर्कों के साथ फ़ंक्शंस को परिभाषित या कॉल करते समय, मैं उन्हें लाइन करने के लिए विम चाहता हूं। उदाहरण के लिए,विम

def myfunction(arg1, arg2, arg, ... 
       argsN-1, argN) 

विचार ArgsN-1 के लिए तर्क है कि इसका 'ए' तर्क 1 के साथ पंक्तिबद्ध है।

क्या किसी के पास यह स्वचालित रूप से विम में होने का कोई तरीका है? मैंने बराबर संकेत (असाइनमेंट कथन में) और इस तरह के अस्तर के लिए संरेखण प्लगइन देखा है, लेकिन मुझे यकीन नहीं है कि इस समस्या को हल करने के लिए इसे बनाया जा सकता है?

उत्तर

7

मेरा मानना ​​है कि आप आदेश जारी करने के लिए है:

:set cino=(0 

यह वह जगह है जब निश्चित रूप से cindent का उपयोग कर।

संपादित करें: मैं याद किया "सेट"

+0

मुझे लगता है कि आप का मतलब: सेट CINO = (0 – rampion

11

पिछले पोस्टर यह था, लेकिन :help cinoptions-values

The 'cinoptions' option sets how Vim performs indentation. In the list below, 
"N" represents a number of your choice (the number can be negative). When 
there is an 's' after the number, Vim multiplies the number by 'shiftwidth': 
"1s" is 'shiftwidth', "2s" is two times 'shiftwidth', etc. You can use a 
decimal point, too: "-0.5s" is minus half a 'shiftwidth'. The examples below 
assume a 'shiftwidth' of 4. 

... 

    (N When in unclosed parentheses, indent N characters from the line 
      with the unclosed parentheses. Add a 'shiftwidth' for every 
      unclosed parentheses. When N is 0 or the unclosed parentheses 
      is the first non-white character in its line, line up with the 
      next non-white character after the unclosed parentheses. 
      (default 'shiftwidth' * 2). 

      cino=      cino=(0 > 
       if (c1 && (c2 ||   if (c1 && (c2 || 
          c3))      c3)) 
        foo;      foo; 
       if (c1 &&     if (c1 && 
         (c2 || c3))   (c2 || c3)) 
       {       { 
+0

टाइपो: एस/सिन्फो/सीनो/​​ –

+3

इंडेंटिंग तब तक काम नहीं कर रहा था जब तक मुझे एहसास नहीं हुआ टोपी टाइप नहीं किया जाना चाहिए था! चर का मान बस है: ** (0 ** –

+1

हाँ, यह शायद दूसरे उत्तर की तुलना में अधिक भ्रमित है – Shitikanth

1

आपको विम फ़िल्टर के रूप में एक भाषा-विशिष्ट बाहरी उपकरण का उपयोग करने से कुछ अच्छा लाभ मिल सकता है। उदाहरण के लिए, आप स्वरूपण आप चाहते हैं उत्पन्न करने के लिए एक Perltidy कॉन्फ़िग फ़ाइल में लिख सकते हैं, तो (ऐसा लगता है कि आप -lp -vtc = 2 झंडे चाहेगा की तरह), आप तो

साथ इसके माध्यम से पाइप के लिए अपने मौजूदा विम बफर कर सकते हैं
:!/path/to/tidy -config /path/to/configfile 

यदि आप आदेश की इस तरह बार-बार चल रहा हो जा रहे हैं, तो आप अपने .vimrc में निम्नलिखित की तरह कुछ डाल कर एक आदेश को परिभाषित कर सकते हैं:

command -range=% Tidy <line1>,<line2>!/path/to/tidy -config /path/to/configfile