简体   繁体   English

Visual Studio HTML代码段。 没有“ td”或“ tr”?

[英]Visual Studio HTML Snippets. No 'td' or 'tr'?

Are there any Visual Studio Snippets for tr or td? tr或td是否有任何Visual Studio片段? I just want to type 'td', hit tab, and have it expand into 我只想输入“ td”,点击标签,然后将其扩展为

<td></td>

This seems fairly basic but I'm unable to find this anywhere. 这似乎很基本,但是我在任何地方都找不到。 I downloaded the HTML Snippet Pack from Visual Studio Marketplace, and even that didn't have them. 我从Visual Studio Marketplace下载了HTML Snippet Pack,甚至没有它们。

Alright, it still blows my mind that I couldn't find any premade 'td' or 'tr' snippets included in any snippet packages. 好了,这仍然令我惊讶,我找不到任何代码片段包中包含的任何预制的“ td”或“ tr”代码片段。

But it turns out creating your own snippet is relatively easy. 但是事实证明,创建自己的代码段相对容易。 https://msdn.microsoft.com/en-us/library/ms165394.aspx https://msdn.microsoft.com/zh-CN/library/ms165394.aspx

For the curious, here is my 'td' snippet: 出于好奇,这是我的“ td”代码段:

<?xml version="1.0" encoding="utf-8"?>  
<CodeSnippets  
    xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">  
    <CodeSnippet Format="1.0.0">  
        <Header>  
            <Title>HTML td</Title>
            <Author>Ethan Fischer</Author>
            <Shortcut>td</Shortcut>
        </Header>  
        <Snippet>  
            <Code Language="HTML">  
                <![CDATA[<td>$end$</td>]]>  
            </Code>  
        </Snippet>  
    </CodeSnippet>  
</CodeSnippets>

To get it working in VS2015, I saved this snippet as a .snippet file in 为了使其在VS2015中正常工作,我将该代码段另存为.snippet文件

Visual Studio 2015/Code Snippets/Visual Web Developer/My HTML Snippets

Then, in Visual Studio, I opened the snippet manager (Ctrl+K, Ctrl+B), clicked 'Import...', found the .snippet file I just created, and added it to one of the suggested locations. 然后,在Visual Studio中,我打开了代码段管理器(Ctrl + K,Ctrl + B),单击“导入...”,找到了我刚刚创建的.snippet文件,并将其添加到建议的位置之一。

Voilà! 瞧! Typing 'td' and pressing tab results in 键入“ td”并按tab会导致

<td></td>

with the cursor in between tags ($end$ tells the snippet where to place the cursor). 将光标放在标记之间($ end $告诉代码段将光标放在何处)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM