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

Allow snippets to start with other characters than alphabetical #35651

Closed
vedmant opened this issue Oct 5, 2017 · 7 comments
Closed

Allow snippets to start with other characters than alphabetical #35651

vedmant opened this issue Oct 5, 2017 · 7 comments
Assignees
Labels
*duplicate Issue identified as a duplicate of another issue(s) snippets

Comments

@vedmant
Copy link

vedmant commented Oct 5, 2017

Currently when I write a snippet it only works when it starts with [a-zA-Z] characters, in my other IDE I have tons of snippets that start like /*=, *=, */, and so on, this is not possible with VS Code unfortunately. Allowing this will really improve my experience as I'm really used to my sets of snippets.

@vscodebot vscodebot bot added editor editor-core Editor basic functionality labels Oct 5, 2017
@chrmarti chrmarti added snippets and removed editor editor-core Editor basic functionality labels Oct 5, 2017
@chrmarti chrmarti assigned jrieken and unassigned alexdima Oct 5, 2017
@jrieken jrieken added the info-needed Issue requires more information from poster label Oct 6, 2017
@jrieken
Copy link
Member

jrieken commented Oct 6, 2017

Please share your snippet, the language in which you are trying this, the exact line contents, and how you are inserting a snippet (via IntelliSense, via the Insert Snippet command, or via tab completion). This is important because there are no restrictions about snippets prefixes in general.

@vedmant
Copy link
Author

vedmant commented Oct 6, 2017

The language is Javascript, for example I have following snippet:

"Comment Section": {
	"prefix": "/*=",
	"body": [
		"/* ========================================================================= *\n * $1\n\\* ========================================================================= */\n",
		"$2"
	],
	"description": "Easily visible comment section"
}

That generates a bold comment separator for a code, like this:

/* ========================================================================= *\
 * Some message
\* ========================================================================= */

It doesn't work however, I tried several prefixes like "*=", "=*", working only those that start with alphabetical letters like "c*", "C=" and so on.

I insert snippet by typing prefix and pressing tab.

I also wanted to add "/*" snippet to generate comments sections like this:

/*
 * Message here
 */

This is something supported by default if other IDEs (there is one asterisk in the beginning).

Other case is Laravel style comments block with prefix: "/*|"

/*
|--------------------------------------------------------------------------
| Comment title
|--------------------------------------------------------------------------
|
| Comment description
|
*/

@jrieken
Copy link
Member

jrieken commented Oct 6, 2017

Thanks for clarifying. So, "yes" the snippets works but "no" the IntelliSense windows doesn't show when typing /*=. That is because we don't trigger 24x7 IntelliSense (the feature of popping up the completion window while you type) on any character but only for those characters that define words... I see how this is annoying but there is no easy fix for this...

Closing this as a duplicate of #32201

@jrieken jrieken closed this as completed Oct 6, 2017
@jrieken jrieken added *duplicate Issue identified as a duplicate of another issue(s) and removed info-needed Issue requires more information from poster labels Oct 6, 2017
@vedmant
Copy link
Author

vedmant commented Oct 6, 2017

So tab key works only when IntelliSense can read the prefix? Maybe there is a way to add a hook for tab key, for example with HTML VS Code has Emmet functionality included, it works on tab key and I think is not connected to IntelliSense.

@jrieken
Copy link
Member

jrieken commented Oct 6, 2017

You must enable tab-completion for this by adding "editor.tabCompletion": true. That will only look at snippets and will insert the snippet that matches the current prefix (no matter what it is). It's very likely what you want

@vedmant
Copy link
Author

vedmant commented Oct 6, 2017

@jrieken That worked! Thanks!

@karolis-sh
Copy link

karolis-sh commented Nov 3, 2017

Adding "editor.tabCompletion": true did not help for my case. I have a snippet:

"Create forEach": {
  "prefix": ".for",
  "body": [".forEach(item => $1)"]
},

image
And as you see, it did not suggest the snippet (tabbing inserts the for loop).

vscode - Version 1.17.2 (1.17.2)
OS - macOS 10.13

@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 20, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*duplicate Issue identified as a duplicate of another issue(s) snippets
Projects
None yet
Development

No branches or pull requests

5 participants