Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use dollar signs/JQuery with Sublime Text 2 Snippets?

Tags:

sublimetext2

I am trying to create some code "Snippets" with Sublime Text2 and everything works fine except when I try and add jQuery code. Apparently any "Snippets" code that includes lines that begin with a $ will simply not work. I couldn't find any answers online regarding this.

like image 962
William Avatar asked Aug 12 '12 06:08

William


People also ask

How do I get snippets in Sublime Text?

Go to Developer Option: Go to the developer option and click on New Snippet. A file will be open with some pre-written code.

How do I use sublime snippets?

To create a new snippet, select Tools | New Snippet…. Sublime Text will present you with an skeleton for a new snippet. Snippets can be stored under any package's folder, but to keep it simple while you're learning, you can save them to your Packages/User folder.

How do I edit a sublime snippet?

Select Package Resource Viewer: Open Resource, navigate down the list to LaTeX, then open the section-.. -(section). sublime-snippet file. You should now be able to edit this file and save it, which will create a new file Packages/LaTeX/section-..

How do I edit snippets in Sublime Text 3?

Tools -> Developer -> View package file -> search for the existing snippet. Change and save.

How to make a snippet in Sublime Text?

Open Sublime Text: Go to Tools: Go to the Tools option and click on it. Go to Developer Option: Go to the developer option and click on New Snippet. A file will be open with some pre-written code.

What does dollar sign ($) mean in jQuery?

What does dollar sign ($) means in jQuery ? - GeeksforGeeks What does dollar sign ($) means in jQuery ? The $ sign is nothing but an identifier of jQuery () function. Instead of writing jQuery we simply write $ which is the same as jQuery () function. A $ with a selector specifies that it is a jQuery selector.

How to remove comments in Sublime Text?

To install Sublime Text, refer to this article. Go to Tools: Go to the Tools option and click on it. Go to Developer Option: Go to the developer option and click on New Snippet. A file will be open with some pre-written code. Edit file: A file will open after clicking on New Snippet. Now, remove the comments as shown below from this opened file.

How to install Sublime Text on Mac?

To install Sublime Text, refer to this article. Go to Tools: Go to the Tools option and click on it. Go to Developer Option: Go to the developer option and click on New Snippet. A file will be open with some pre-written code. Edit file: A file will open after clicking on New Snippet.


1 Answers

Did you try escaping the $ with a \?

For instance in PHP, the $GLOBALS snippet is:

<snippet>     <content><![CDATA[\$GLOBALS['${1:variable}']${2: = }${3:something}${4:;}$0]]></content>     <tabTrigger>globals</tabTrigger>     <scope>source.php</scope>     <description>$GLOBALS['…']</description> </snippet> 

As you can see in <content>, $GLOBALS is expressed as \$GLOBALS. This is because $ is a symbol used for fields like ${1:variable}.

like image 66
Zendmailer Avatar answered Sep 30 '22 19:09

Zendmailer