Git Product home page Git Product logo

convert-snippets-to-vscode's Introduction

Convert Textmate or Sublime Code Snippets to VSCode

Based off the VSCode Yeoman generator, I have created a script to convert Textmate or Sublime snippets to a VSCode snippet json file. The intent is to be able to have multiple snippet language types in a single VSCode extension but the Yeoman template generator only does 1 snippet language.

One other difference from the VSCode Yeoman generator, is that if will recursively look through the given directory for the snippets.

Install the Converter

npm install convert-snippets-to-vscode
npm install -g convert-snippets-to-vscode

Run Converter

To launch the converter and be prompted for info simply type:

$ snippetToVsCode

Folder location that contains Text Mate (.tmSnippet) and Sublime snippets (.sublime-snippet)
? Folder name: c:\temp\Snippets\Css
? Output File Name: c:\temp\css.json 

To launch to convert and pass in command line arguments:

snippetToVsCode -s c:\temp\Snippets\Css -o c:\temp\css.json

Converter Output

A json file with the converted templates in the vscode format.

Take the generated file, add it to your VSCode Extension that you generated with VSCode Yeoman generator in the snippets directory.

Then update the package.json file in your VSCode Extension project with the new snippets file name and language that it supports.

License

MIT

convert-snippets-to-vscode's People

Contributors

digitaldrummerj avatar

Stargazers

Tekin Tian avatar Curt Sheller avatar Sanchit Sinha avatar Kieran avatar Kamil Mielnik avatar showitz avatar  avatar Andrey avatar Aubrey Portwood avatar Anubhav Ujjawal avatar kang taehee avatar Josef Friedrich avatar Nick Koutrelakos avatar  avatar Antonio Gil avatar Mark Shi avatar Darkø Tasevski avatar Rafael Rozon avatar  avatar Victor Camargo avatar milad jafari avatar

Watchers

 avatar James Cloos avatar milad jafari avatar

convert-snippets-to-vscode's Issues

Un escapes $

If you have escaped $ in a sublime snippet, it will be unescaped hence breaking the snippet

E.g
Sublime text

<snippet>
	<content><![CDATA[
Hello, ${1:\{\{ \$object->field \}\}} is a ${2:snippet}.
]]></content>
	<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
	<tabTrigger>hello</tabTrigger>
	<!-- Optional: Set a scope to limit where the snippet will trigger -->
	<!-- <scope>source.python</scope> -->
</snippet>

Output

"hello": {
		"prefix": "hello",
		"body": "\nHello, ${1:\\{\\{ $object->name \\}\\}} is a ${2:snippet}.\n",
		"description": "",
		"scope": ""
	}

Notice the escaped doller sign before object in the sublime snippet is unescaped in the resulting vscode snippet. This may break your code when you desire a result which includes the doller sign for php variables.
Result from the sublime snippet

Hello, {{ $object->name }} is a snippet.

Result from vscode snippet

Hello, {{ object->name }} is a snippet.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.