Sublime Doctype HTML Snippet

房东的猫 提交于 2019-12-06 09:21:25

问题


Is there a way that this here below ↓↓↓ can be inserted as a snippet?

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title></title>

</head>
<body>

</body>

</html>

I tried using Preferences -> Key Bindings - User but quotation marks really matters.


回答1:


You can create a new snippet via Tools -> New Snippet...

You can read more about creating and using snippets here.

FYI, the HTML5 doctype is probably more appropriate and much easier to remember, simply:

<!DOCTYPE html>



回答2:


Just to spell it out, so you don't need to follow links:

After selecting Tools -> New Snippet..., modify its content to the following:

<snippet>
    <content><![CDATA[
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>$0</title>

</head>
<body>

</body>

</html>
]]></content>
    <tabTrigger>newpage</tabTrigger>
    <scope>text.html</scope>
</snippet>

The $0 between the <title> tags indicates that your cursor will end up here after triggering the snippet. If you'd like to have multiple insertion points that you can Tab between them, use $1 as the first, $2 as the second, etc., using $0 as the final spot.

Save the snippet in your Packages/User directory (it should be the default when you hit save) as newpage.sublime-snippet. To test it, open a new file, set the syntax to HTML, type newpage, and hit Tab, and you should be all set.



来源:https://stackoverflow.com/questions/24987632/sublime-doctype-html-snippet

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!