Sublime Forum

Snippets, zen coding

#1

Hello all sublimers :smile:,
Im new here and first I want to say that i love Sublime Text, i was using notepad++ and i still miss some of the features but i hope they will be implemented later.

So here is what i want to do:
I want to create a snippet to insert HTML5 doctype, meta tags etc.
Here is the code of the snippet:

<snippet>
	<content><![CDATA[<!DOCTYPE html>

<html lang="en">
<head>

	<meta charset="utf-8" />
	<meta name="author" content="" />
	<meta name="description" content="" />

	<title>$1</title>

	<!-- Include CSS -->
	<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
	<link rel="stylesheet" href="css/style.css" />

	<!-- Include jQuery -->
	<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>

	<!-- Include functions -->
	<script src="js/functions.js"></script>

</head>]]></content>
	<tabTrigger>html5</tabTrigger>
	<description><!doctype html></description>
</snippet>

But when i try to save it, i get this error:

No content for snippet Packages/HTML5/DoctypeHTML.sublime-snippet

And when i try to trigger the snippet, it just doesnt do anything.


And actually i just noticed that when i use zen coding, and for example i want to do something like ul>li and i press tab,
this is what i get:

ul><li><a href="" title=""></a></li> li
instead of just <ul><li></li></ul>
Is there any way to fix this? Because it seems like there is something wrong with zen coding.

I hope its not too much,
Thanks in advance :smile:

0 Likes

#2

[quote=ā€œSh4d0Wā€]
And actually i just noticed that when i use zen coding, and for example i want to do something like ul>li and i press tab,
this is what i get:

ul><li><a href="" title=""></a></li> li
instead of just <ul><li></li></ul>
Is there any way to fix this? Because it seems like there is something wrong with zen coding.

I hope its not too much,
Thanks in advance :smile:[/quote]

This works correctly for me, although I have to hit Enter after ā€œul>liā€ rather than tab. Just to be clear, are you entering the Zen Coding string after launching the input panel by ctrl+alt+enter? Iā€™m using ST2 2143 on OS X, not sure which version of Zen Coding.

0 Likes

#3

Actually when i type it in the panel (ctrl+alt+enter) it works, tho when i type it in the document and then press tab to expand it messes up.
Well it looks like i will have to use this method instead, thanks :smile:.

And btw do you know why the snippet thing doesnt work?

0 Likes

#4

Iā€™m trying to get how to add custom snippets to zen coding plugin (ZC) of my Notepadd++. I found the file where ZC stores its snippets - C:\Program Files\Notepad++\plugins\NppScripting\includes\Zen Coding.js but I have some questions:
What the difference between ā€˜snippetsā€™ and ā€˜abbreviationsā€™ ?
ZC expands typed abbreviations differently in different contexts. For examle z+ctrl+e sometimes expands as z-index:|; and sometimes as ā€¦ How does ZC recognize context ?

0 Likes