The Snippets Editor is somewhat less than optimal in the following ways:
    Adding new Snippets is unintuitive: At first I had thought that this feature was disabled. After playing around I realized that changing the shortcut name of an existing shortcut to something new enabled the "Add Snippet" button. When playing around with creating snippets I was constantly switching back and forth between the SQL Prompt Dialog and the editor to test it out. To save the snippet OK has to be pressed on the SQL Prompt Dialog, which also minimizes it to the tray. Then I would try it out, and if I needed to edit it I would have to double click the tray icon to bring the dialog back. While the dialog would remember that I was on the "Auto Insert" tab and would also remember the values for "Shortcut" and "Code" it would lose the "Saved Snippets" listbox selection. The effect of this is upon the first keystroke of editing the "Code" textbox would cause the "Save Snippets" listbox to re-find it's selection, which would then cause the carret to go to position 0 of the "Code" textbox and the keystroke is eaten. Ideally I would like to test the snippets in the Sql Prompt dialog itself, but I also realize that each editor treats the keystrokes differently and it wouldn't be a true test. Lastly since there is no help there is no Snippets Code syntax reference. I realize that it happens to be the exact same as the SendKeys API but it did take a couple minutes for the light bulb to go on over my head.
ChrisRickard
0

Comments

6 comments

  • kkozera
    When creating snippets with parens in them, the parens are not being included when the snippet is executed

    On multi-line snippets: I put my cursor a few tabs into the code window and executed the snippet. The first line of code started at my cursor position, but the following lines started back at the left side.
    kkozera
    0
  • ChrisRickard
    kkozera wrote:
    When creating snippets with parens in them, the parens are not being included when the snippet is executed

    Parens must be escaped with braces {}, so say you wanted
    GETDATE()

    the snippet syntax would be
    GETDATE{(}{)}

    (edited to fix bbcode)
    ChrisRickard
    0
  • ChrisRickard
    Another thing I found that happens is if I were to give an invalid snippet syntax then use it in the editor random chunks of the output get skewed. While this is understandable (garbage in, garbage out) it effects the snippets engine from then out. Other correct snippets start behaving the same way and other odd things will happen even after the erroneous snippet is fixed. The only way to get around it is to restart the SQL Prompt app.
    ChrisRickard
    0
  • kkozera
    Thanks ChrisRickard!
    kkozera
    0
  • ChrisRickard
    kkozera wrote:
    On multi-line snippets: I put my cursor a few tabs into the code window and executed the snippet. The first line of code started at my cursor position, but the following lines started back at the left side.

    This is because each character is a literal keystroke sent to the editor. So an editor like QueryAnalyzer or SSMS will behave like this becuase the same thing would happen if you were to manually type in the snippet. Visual Studio on the other hand has smart indentation that auto-inserts
    the tabs for you.

    Perhaps that could also be a new feature: inserting smart indentations.
    ChrisRickard
    0
  • itlee
    I think you need to use the escape characters {} around any character that requires the shift key to be pressed.

    for example: I created a snippet for LIKE '%%', so when I used the shortcut SQLPrompt entered LIKE ' but then it was as if the Alt key had been pressed and the menus where highlighted.

    So, I had to create the snippet as LIKE '{%}{%}'

    This was in Query Analyzer
    itlee
    0

Add comment

Please sign in to leave a comment.