Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I add custom snippets? #125

Open
neopostmodern opened this issue Apr 25, 2018 · 2 comments
Open

How do I add custom snippets? #125

neopostmodern opened this issue Apr 25, 2018 · 2 comments

Comments

@neopostmodern
Copy link

I tried copying one of the files in brace/snippets/ and loading it from my own sources, but that seems to have no effect.
Also, calling brace.acequire(...) manually for the defined virtual path is without effect.

Any hints?

@kmorizur
Copy link

Hi,

In order to add your custom snippet (for example for sql mode) you need to :

`const { snippetManager } = ace.acequire('ace/snippets');

const customSnippetText = [
"snippet log",
" console.log("${1:}")",
""
].join('\n');

const customSnippet = snippetManager.parseSnippetFile(customSnippetText, 'sql');

snippetManager.register(customSnippet, 'sql');`

@hughfenghen
Copy link

hughfenghen commented Aug 31, 2019

Note: snippet content must be start with \t, example:

const customSnippetText = [
  'snippet log',
  '\tconsole.log("${1:}")',
].join('\n');

Otherwise an error(text.match is not a function) will be thrown when selecting a snippet .
Because snippet content is undefined. parseSnippetFile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants