Re: Re-Map Keys in SQL Server Management Studio

It's great to have vi editing keys in SMS.  I'd like to be able to switch between tabs in the editor with CTRL-PGDOWN and CTRL-PGUP like the browsers allow (instead of CTRL-F6/CTRL-SHIFT-F6 like SMS has natively)

Can I do that with ViEmu?


Re: Re-Map Keys in SQL Server Management Studio


Apologies for the delay in answering. Unfortunately, SQL Server Management Studio is quite poor in keyboard remapping possibilities. ViEmu can be shoehorned into fixing some of this, but the possibilities are limited. For example, ViEmu mappings only work in text editor windows.

Since SSMS is derived from VS 2005, I checked it and the command ":vsc Window.NextDocumentWindowNav" actually moves to the next window (same as Ctrl-F6). I obtained the command name from going to VS2005's keyboard config window and checking what command Ctrl-Tab is mapped to.

Then I checked whether I could map a simple key like "PageDown" to this command. I did it like this:

  :nnoremap <pagedown> :vsc Window.NextDocumentWindowNav<return>

Indeed, this worked, and it makes <pagedown> move to the next window while in a text editing window.

I stumbled into the actual problem for your goal when trying to map it to <c-pagedown>. It turns out SSMS already has that key mapped to some internal command (it seems it's the same as Ctrl-End, which takes you to the end of the current document). Unfortunately, it is impossible to un-bind this keypress from that command, and thus the keypress never reaches ViEmu.

The very poor keyboard configurability is a limitation of SSMS itself. I'd think about trying to overcome it somehow, but I suppose MS themselves will be fixing this in a future SSMS release, so it's probably not sensible to invest a lot of effort in that area.

Thanks and best regards,

  -- Jon