SQL Server – Shortcuts for Code Snippets in SSMS

sql serverssms

In SSMS I would like to use shortcuts for code snippets, just like in Visual Studio:

type 'shortcut'; hit TAB -> snippet expanded

In SSMS I need to CTRL+K, CTRL+X, mouse, mouse, find, go back, find, mouse. This is not a shortcut, nothing "short" about it.

I've added this sample snippet to my list of snippets:

<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
  <CodeSnippet Format="1.0.0">
    <Header>
      <Title>Transaction</Title>
      <Author />
      <Description>Transaction wrapper</Description>
      <HelpUrl />
      <SnippetTypes />
      <Keywords />
      <Shortcut>tra</Shortcut>
    </Header>
    <Snippet>
      <References />
      <Imports />
      <Declarations>
        <Literal Editable="true">
          <ID>TSQL</ID>
          <Type />
          <ToolTip />
          <Default>TSQL</Default>
          <Function />
        </Literal>
      </Declarations>
      <Code Language="SQL"><![CDATA[
BEGIN TRANSACTION TRAN1
$TSQL$
ROLLBACK TRANSACTION TRAN1]]>
      </Code>
    </Snippet>
  </CodeSnippet>
</CodeSnippets>

I can find it via CTRL+K, CTRL+X, but I'm unable to invoke it by tra + TAB shortcut. Am I missing something? Can SSMS even do this?

I'm using SSMS v13.0.16100.1, but database is SQL Server 2014.

Best Answer

No, while the XML schema contains a shortcut element, the fact is that proper shortcut support was never implemented (several of the other elements are not visible outside the XML, either). The following Connect item was closed as "Won't Fix" back in 2013:

You may be able to raise awareness of this issue on another place where the SSMS team is paying attention: trello. But I'll warn you: even with an accelerated dev and release cycle, they have a lot on their plates, and I'm not sure this could make any significant dent into the top, say, 50 enhancements.

(Personally, I haven't found that I've need to use my mouse to insert snippets - all that is needed is keystrokes. Obviously YMMV.)