jon skulski
jon skulski

Reputation: 2305

Standard IDE/editor format for expanding snippets?

Is there any kind of standard across editor and IDEs for expanding snippets?

Specifically, I would like to write a patch for an API that would provide a code snippet database that could be imported into different editors/IDEs and expand on demand.

I am writing something for vim (my editor of choice so that)

:expand theme_some_function  

would then insert

/**
 * Override of theme_some_function($&arg)
 **/
MYMODULE_some_function(&$arg1) { 
  // contents of the function go here
}

which is how you override a function in Drupal.

Originally I was writing this so that it would go find the file through ctags and copy the function and s/foo/bar/ what needs to be changed. It was suggested that I could expand this to other editors, so I was wondering if there was a standard that I might use.

But in general, is there any kind of editor standard that might give me ideas about opportunities to write something for many editors at once?

Upvotes: 0

Views: 107

Answers (2)

Basil Bourque
Basil Bourque

Reputation: 339502

I've not found any such standard. But here are a few points for exploration.

• Microsoft publishes a spec for an XML-based format of code snippets.

Code Snippets Schema Reference (Visual Studio 2012)

• Wikipedia has an article on code snippets but makes no mention of standards.

This web page for Code Collector Pro (Mac OS X app) mentions:

Support for .snippet Files – A new common file format for all snippet managers

…but provides no information or links about such a format.

Upvotes: 0

Nathaniel Flath
Nathaniel Flath

Reputation: 16025

There isn't really any such editor standard, no.

Upvotes: 1

Related Questions