Visual Studio 2012 shortcuts not working for SQL

I have my own code snippet that I can only get with Ctrl + K, Ctrl + X, and then typing 'm' for 'My Code Snippets' and pressing Tab, and then typing the first letter of the snippet that I want then click Enter

By this time it is almost shorter, just to pick up the real thing.

I tried to assign the key combination Edit.InvokeSnippetFromShortcut (Tools> Options> Environment> Keyboard), but although it allows me to assign and save a shortcut by typing a shortcut for fragments, and then enter the shortcut that I assigned to InvokeSnippetFromShortcut, nothing. This may be due to the fact that it does not appear in the "Edit" menu, where it looks (due to a small number of search queries), as if it should be located, so it may not be available.

Background: I am editing a .sql file, so this is a SQL fragment. Below is an example of fragment behavior for C #, VB, etc. My custom snippet has "sql" as the language (I tried with sql_ssdt with the same result). I just want to be able to type "foo", press one key combination, and the editor replaces "foo" with "barbaz_some_long_thing_that_is_tedious_to_type"

Has anyone got this job? If so, how?

+4
source share
1 answer

It sounds like a job for AutoHotKey . You can create an .ahk script to listen to the "hot lines" (everything that is typed on the keyboard, and then add conditions such as opening a specific window). I use this command to detect Visual Studio

Vis() { SetTitleMatchMode 2 IfWinActive, Microsoft Visual Studio { return 1 } else { return 0 } } 

So you can write this command

 :*:foo:: if Vis() = 1 { SendInput bar } else { SendInput foo } return 

Typing foo in Visual Studio will run the snippet and instead send the input bar . Entering foo in any other window will simply display foo as usual. AutoHotKey installation is quick and much easier than trying to work within the limitations of VS.

+1
source

All Articles