code-snippets

How can I add language-agnostic snippets in vscode?

≯℡__Kan透↙ 提交于 2019-12-24 07:49:26
问题 As an example I would like to add "lorem ipsum" as a snippet, so I can quickly insert it where I want. I don't want it do be tied to a specific language, as I might use it in multiple places like HTML, Jade, even JS/TS. Is there like a global.json for snippets, or any other way to do this? 回答1: Global snippets were added in v1.10 Feb., 2018 see global snippets VS Code now supports global snippets meaning snippets that aren't scoped to a single language but can target any kind of files. Using

Sublime Text 3 - Snippet doesn't fire on tab, only on CSS file

寵の児 提交于 2019-12-24 04:41:29
问题 I have a snippet that does not fire on the tab trigger. Here's my code... <snippet> <content><![CDATA[ .contentBox ul{list-style: none; padding: 0;} .contentBox ul li{padding-left: 2.5em; text-indent: -0.7em; margin-bottom: 4px;} .contentBox ul li:before{content: "${1:•} "; color: #${2:Bullet color};} ]]></content> <!-- Optional: Set a tabTrigger to define how to trigger the snippet --> <tabTrigger>xcv</tabTrigger> <!-- Optional: Set a scope to limit where the snippet will trigger --> <!--

VsCode - Triggering a snippet upon file creation

╄→гoц情女王★ 提交于 2019-12-24 03:36:18
问题 I wanted to know if it is possible to trigger a user defined custom snippet when I create a file in vscode. I started learning Golang recently and noticed that there is some boilerplate code that goes into creating the main.go file. So I created my custom snippet for it and now now I can trigger the snippet manually and save me some keystrokes of typing. I wanted to go one step further, so that whenever I create a new file named main.go from within VsCode, it should automatically fire that

Visual Studio 2008 code snippet doesn't add Reference Assembly and/or Import Namespace

心不动则不痛 提交于 2019-12-24 03:32:46
问题 I'm developing some code snippet, and I experienced that Visual Studio doesn't automatically add Reference to specified assembly and doesn't import the specified namespace. My snippet definition is: <?xml version="1.0" encoding="utf-8"?> <CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"> <CodeSnippet Format="1.0.0"> <Header> <Title>MyTryCatch</Title> <Shortcut>myTryCatch</Shortcut> </Header> <Snippet> <References> <Reference> <Assembly>MyAssembly.dll</Assembly>

ST3 swap priority of tab function within a snippet (nested snippets)

孤街浪徒 提交于 2019-12-24 01:46:08
问题 Find myself frequently invoking a snippet within a snippet, but of course when I go to expend the nested snippet, the tab key moves me to either the next entry of the first snippet or the end of the first snippet (at which point, I have to replace the cursor at the end of the tab-trigger expression for the 2nd snippet and hit tab, at which point the 2nd snippet is expanded). eg. given snippet [ content A ${1:First point in A} and ${2: Second point in A} ] with tab-trigger tabtrigA and snippet

How to complete a Visual Studio snippet in VB.NET?

冷暖自知 提交于 2019-12-23 08:54:02
问题 In C# if you start a snippet you press Tab to cycle through the snippet elements, and press Enter to complete and exit the snippet. In VB.NET you still use Tab to cycle through the snippet elements, but how do you end the snippet? Enter doesn't work and I can't figure out the correct keyboard shortcut 回答1: VB snippets don't work the same way as C# snippets. VB snippets don't have an 'end' and instead stay active until you start typing outside of the snippet scope. The best method is to press

Resharper: Code snippets with tab+tab

点点圈 提交于 2019-12-23 08:30:15
问题 In VS, to use snippets (for example auto-implented property) I typed "prop", then hit TAB twice. However R# (I'm using R#6) inserts the snippet after ONE tab, causing me to always mistype something. Is there an option somewhere, where I can set it to use two tabs ? 回答1: Unfortunately there's no way that I'm aware of that would let you reassign deployment of ReSharper live templates to two tab hits instead of a single hit. However, until you've got used to the single-tab deployment, you can

How do I delete an Imported Snippet in Visual Studio?

依然范特西╮ 提交于 2019-12-23 07:00:09
问题 I imported a snippet, and I want it gone. Problem is that the Snippet Manager has the Remove button grayed out when I go in and try to remove it, any ideas? 回答1: Chances are that code snippet was imported to Program Files folder (e.g. C:\Program Files (x86)\Microsoft Visual Studio 11.0\Web\Snippets\CSS\1033\CSS) instead of C:\Users\\Documents\Visual Studio 2012\Code Snippets Snippet Manager displays the location of selected snippet, just go there, delete it manually and restart Visual Studio.

XML code snippets to browser friendly HTML

和自甴很熟 提交于 2019-12-23 01:52:10
问题 Is there an online tool to convert XML code snippets to browser friendly html? I just want to post my XML code to a forum for viewing purposes and nothing else but the TAGs mess up the HTML. 回答1: To display strings containing reserved characters in HTML ( < , > and & ), you need to convert those characters into HTML entities. For example, the HTML entity for < is < . There are tools in most languages for converting reserved HTML characters into entities. For example, in PHP, you can use the

VS Code snippet - escape ${file}

无人久伴 提交于 2019-12-22 03:43:20
问题 I'd like to create a snippet in VS Code, which includes exact string ${code} . However, when I enter it in this form, VS Code tries to interpret it as snippet parameter. How should I escape it properly? 回答1: "}" AND "$" can be escaped with "\\". Some cases "$" can be escaped with "$$" but not in your case. Your snippet should look like this. "Return Code With Squirly And Dollar": { "prefix": "code_snippet", "body" : [ "\\${code\\}" ], "description": "Code Snippet" } This should help you 来源: