0

I am trying to create a Javascript snippet for Visual Studio 2015 Update 2. It should expand into something like:

myObject.HIGHLIGHT_THIS_METHOD_FOR_REPLACING.something();

I could create expansion snippet. I type the shortcut and double tap tab, and it expands. However, it doesn't highlight "HIGHLIGHT_THIS_METHOD_FOR_REPLACING" part. I'm following the tutorial at https://msdn.microsoft.com/en-us/library/ms165394.aspx and I'm stuck. Here is my snippet:

<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <SnippetTypes>
        <SnippetType>Expansion</SnippetType>
      </SnippetTypes>
      <Title>MyTitle</Title>
      <Author>Can Poyrazoğlu</Author>
      <Description>My Description
      </Description>
      <HelpUrl>
      </HelpUrl>
      <Shortcut>myShortcut</Shortcut>
    </Header>
    <Snippet>
      <Code Language="javascript"><![CDATA[myObject.$HIGHLIGHT_THIS_METHOD_FOR_REPLACING$.something();]]></Code>
    </Snippet>
    <Declarations>
       <Literal>
        <ID>HIGHLIGHT_THIS_METHOD_FOR_REPLACING</ID>
        <ToolTip>Some tooltip</ToolTip>
        <Default>something</Default>
    </Literal>
    </Declarations>
  </CodeSnippet>
</CodeSnippets>

I am getting myObject..something(); as the expansion, with no default valur for the literal part and with the cursor at the beginning of the whole text (just before myObject), which kills the whole point of the shortcut.

What am I doing wrong?

1 Answer 1

1

According to the document and the XML sample you provided, I tested in both VB and Javascript in VS2015 (with Update 1 and Update 3) and VS2013 with Update 5. I get the same issue with you in VS2015. But in VS2013, the replacements are all display but without highlighted.

I have submit this issue to Visual Studio Connect with detailed steps. Please vote and add your comments for this issue. Before this issue resolved, I suggest you add the replacement content manually.

https://connect.microsoft.com/VisualStudio/feedback/details/3110313/replacements-element-in-code-snippet-doesnt-work

Sign up to request clarification or add additional context in comments.

3 Comments

Thank you Wendy for your effort for submitting. I've +1'd it and added as a repro. I hope this is fixed soon as VS Javascript IntelliSense still has a long way to go and if they're serious about web development, they have to fix it.
Please mark the answer which could let other communities who has the same issue to vote and add comments. Thanks.
I've upvoted the answer as I think it's helpful, but I cannot mark it as it does not provide a canonical answer to the question itself.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.