2015-12-12 13 views
25

में अतिरिक्त नई लाइन डालने के लिए मैंने विजुअल स्टूडियो में उपयोग के लिए एक कस्टम स्निपेट बनाया है। वीएस2013 में, यह अपेक्षित के रूप में काम करता था, लेकिन वीएस2015 (सामुदायिक संस्करण) में इसका उपयोग करने के बाद से यह कोड से पहले एक अतिरिक्त नई लाइन डालने जा रहा है (ठीक है जब मैं टैब दबाता/दूसरी बार दर्ज करता हूं)।स्निपेट वीएस2015

ऐसा लगता है कि यह केवल कस्टम स्निपेट (अंतर्निर्मित काम ठीक है) के साथ एक समस्या है। किसी को पता है कि इसका कारण क्या हो सकता है? यह अत्यधिक दुखी कर रहा है।

एक साइड नोट के रूप में, यह केवल तब होता है जब मैं कोड की खाली रेखा पर स्निपेट सक्रिय कर रहा हूं। यदि मैं मौजूदा कोड के बाद ऐसा करता हूं, तो नई लाइन डाली नहीं जाती है। दुर्भाग्य से, स्निपेट एक बयान है, इसलिए इससे ज्यादा मदद नहीं मिलती है।

यहाँ टुकड़ा, वी.एस. नमूना से लगभग पूरी तरह से कॉपी किया है:

<?xml version="1.0" encoding="utf-8" ?> 
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/CodeSnippet"> 
<CodeSnippet Format="1.0.0"> 

    <!-- The header contains information describing the snippet. --> 
    <Header> 

     <!-- The Title of the snippet, this will be shown in the snippets manager. --> 
     <Title>Insert Field Add</Title> 

     <!-- The description of the snippet. --> 
     <Description>Inserts a basic field add for a DataObject</Description> 

     <!-- The author of the snippet. --> 
     <Author>Thomas Price</Author> 

     <!-- The set of characters that must be keyed in to insert the snippet. --> 
     <Shortcut>fadd</Shortcut> 

     <!-- The set of snippet types we're dealing with - either Expansion or --> 
     <SnippetTypes> 
     <SnippetType>Expansion</SnippetType> 
     </SnippetTypes>   

    </Header> 

    <!-- Now we have the snippet itself. --> 
    <Snippet> 
     <!-- Create any declarations that we use in the snippet. --> 
     <Declarations> 
      <Literal> 
      <ID>FieldName</ID> 
      <ToolTip>Enter the field name</ToolTip> 
      <Default>field</Default> 
      </Literal> 
     </Declarations> 

     <!-- Sepecify the code language and the actual snippet content. --> 
     <Code Language="CSharp" Kind="any"> 
      <![CDATA[$FieldName$ = fields.add($FieldName$, "$FieldName$");]]> 
     </Code> 
    </Snippet> 
</CodeSnippet> 

+0

संभावित डुप्लिकेट (https://stackoverflow.com/questions/33297458/visual-studio-code-snippets-extra-line) –

उत्तर

34

आप अपने टुकड़ा पाठ में कहीं $ अंत $ रखकर पूर्ववर्ती न्यू लाइन रोका जा सकता है। उदाहरण:

<![CDATA[$FieldName$ = fields.add($FieldName$, "$FieldName$");$end$]]> 
[दृश्य स्टूडियो कोड अतिरिक्त लाइन के टुकड़े] की
+2

वहाँ एक '$ है $ भी शुरू करें? – Ciwan

+0

@ सीवान स्पष्ट रूप से नहीं। मैंने कोशिश की और इससे मेरे स्निपेट पर कोई फर्क नहीं पड़ता – Nick

+1

यहां [पूर्ण विनिर्देश संदर्भ] है (https://docs.microsoft.com/en-us/visualstudio/ide/code-snippets-chechema-reference#code)। 'कोड' तत्व के पाठ में उपयोग के लिए केवल "दो आरक्षित शब्द उपलब्ध हैं:' $ end $ 'और '$ $ चुना गया'।" @Ciwan – Draco18s

संबंधित मुद्दे