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

Snippet for Markdown File #1617

Closed
gep13 opened this Issue Dec 23, 2015 · 8 comments

Comments

Projects
None yet
4 participants
@gep13
Contributor

gep13 commented Dec 23, 2015

I am trying to create a snippet for Markdown file, but nothing I seem to try is working.

These are the steps that I have followed:

  1. Open Visual Studio Code
  2. Open a markdown file, i.e Readme.md
  3. Press F1, type snippet, select Create Snippet
  4. Entered the following:
 "Test Snippet": {
  "prefix": "gep13",
  "body": [
   "test $1"
  ],
  "description": "Your snippet description here."
 }
  1. Saved the file, and then went back to the markdown file, and typed gep13 but the snippet never appears.

Any idea as to why this isn't working? I have read through this: https://code.visualstudio.com/docs/customization/userdefinedsnippets and it suggests that snippets for markdown files should work, but it doesn't seem to.

I have tried opening/closing VS Code, but still nothing. I am using VS Code version 0.10.5.

@egamma

This comment has been minimized.

Member

egamma commented Dec 23, 2015

This works for me, notices the top-level {} that you seem to have removed, they are required.

{
    "Test Snippet": {
        "prefix": "gep13",
        "body": [
            "test $1"
        ],
        "description": "Your snippet description here."
    }
}

@egamma egamma closed this Dec 23, 2015

@gep13

This comment has been minimized.

Contributor

gep13 commented Dec 23, 2015

@egamma sorry, but I also have those:

image

Can you confirm exactly what you mean by working? I have an expectation that when editing any file with a .md or .markdown extension, that when I type gep13 I should have an option to expand that into the snippet, but that is not happening for me.

Is there anything that I can do to debug this further?

@egamma

This comment has been minimized.

Member

egamma commented Dec 23, 2015

Can you confirm exactly what you mean by working?

The gep13 snippet shows up when I edit a markdown file.

Here are my steps:

  • preferences>user snippets
  • select markdown in the quick box
  • add the snippet to the file that opens

Now open a markdown file

  • type gep and press ctrl-space, the snippet shows up.
@gep13

This comment has been minimized.

Contributor

gep13 commented Dec 23, 2015

Ah, interesting, the Ctrl-Space is required. In the Latex extension, and the Cake extension, the snippets there seemed to automatically appear, without the need for pressing Ctrl-Space. What magic is happening in those extensions to make that just work?

For example, in the Latex extension, I was able to type cha and the snippet appeared automatically, without the need to press ctrl-space. Thanks!

@egamma

This comment has been minimized.

Member

egamma commented Dec 23, 2015

Yes this is an inconsistency. Full extensions get auto (7x24) completion by default (e.g. latex, cake), some built-in extensions like Markdown do not.

@gep13

This comment has been minimized.

Contributor

gep13 commented Dec 23, 2015

@egamma gotcha, ok, so the world makes sense again, at least for now 😄 Thanks for all your help with this!

@TJSoftware

This comment has been minimized.

TJSoftware commented Mar 29, 2016

👍 the Ctrl-Space was not expected.

Are there any others outside of markdown that require the use of Ctrl-Space?

Asking out of ignorance here, is this something that markdown files can be made into an extension like C# is an extension?

@bcsjk11

This comment has been minimized.

bcsjk11 commented Aug 13, 2017

Didn't know about the Ctrl+Space either until I read this here. +1 on wanting this to be build in by default. Or at least have a clear guide on what languages are support 24x7 and which are not for this.

@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 18, 2017

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.