1

Re: Execute Macro for SQL Server

Is there someway to mimic the behavior of toad. You can just point anywhere and hit an execute button and it executes the "current statement". Basically its defined by white space - blank lines fore and aft of the current line. I'm wondering if anyone has written something like that for ViEmu - a one key execute.

2

Re: Execute Macro for SQL Server

I would think that would be fairly easy.  I don't have the SQL Server version so I can't verify it but try this:

map <whatever> vipgS<F5>

- Les

NOTE: I left out the gS the first time around so I edited it

Last edited by lnoland (2008-03-13 17:38:30)

3

Re: Execute Macro for SQL Server

Thanks Les! Indeed that should help out, but <F5> won't work - it doesn't get routed to VS. It would be necessary to invoke the query directly using ViEmu's ":run" command:

  map <whatever> vipgS:run<return>

This was covered in some more detail here:

  http://www.viemu.com/forums/viewtopic.php?id=169

4

Re: Execute Macro for SQL Server

Thanks for the input guys. (I note that I must have forgotten that I added a comment to that other topic - 169 - Alzheimers is setting in early). So I was able to map this to the C-N key (but I prefer to use that for :noh). I tried C-E but that bypasses VIEMU and just executes. How can we find out what keys can be mapped and which can't?

And I also added a imap command which starts with <esc> so that you can hit the magic key while in insert and still get the correct behavior.

Last edited by smorley (2008-03-13 18:24:59)

5

Re: Execute Macro for SQL Server

>How can we find out what keys can be mapped and which can't?

For ViEmu mappings, until the :map<CR> command gets implemented I suspect that you can't.  Hopefully, when that is implemented it will at least list all mappings done by the user and ViEmu itself.  I would venture that it probably would not, however, show those mappings due to the underlying tool (e.g. Visual Studio, SQL Management Studio) since these might not be easy to determine programmatically and besides, the RHS would be something foreign to ViEmu.

In both Visual Studio and SQL Management studio, you can at least test a keymapping by choosing Tools->Options and then selecting Keyboard from the tree-list in the resulting dialog or via  the special "Keyboard" button in the dialog from Tools->Customize (the button just takes you to the aforementioned tree-list item).  In SQL Management studio, you will just see a list of all the key mappings, which is generally fairly short.  In Visual Studio, however, I think you pretty much have to try out your proposed mapping on an existing VS command (it doesn't matter which one -- just be careful not to select "Assign" when you are doing this).  If you enter a mapping for a command which is already mapped to something else, the current mapping will be displayed.

Years ago, when Microsoft Help actually was a help, there was a Keyboard item in the help menu for Visual Studio which, when selected, would give you a list of all of the current Keyboard mappings with a short description of the command to which each was mapped.  If there is anything close to that now it is well-hidden because I have looked. sad

- Les

6

Re: Execute Macro for SQL Server

Its odd that I could not map to Ctrl-E but I could map to Ctrl-N (SQL Management Studio). I'm guessing that you can't remap keys which already have a function in SMS. I could also not map to F1. So, in the end I used ALT-E which sort of mimics the Ctrl-E but with the enhanced functionality. In the end it all works great - I have a single keystroke which will highlight the current "paragraph" and execute it. This is going to save me a lot of aggravation as I usually code with bunched of statements that I have to selected before I can execute.

7

Re: Execute Macro for SQL Server

Great to hear that! Indeed, keyboard management is somewhat complex and you have to either remove SSMS keybindings, or use ones with do not clash with them. ViEmu 3.0 will have better support for this.

8

Re: Execute Macro for SQL Server

So I tried to get this pretty fancy and restore the cursor to its position, but it does not work
  map <A-E> mzvipgS:run<return><esc>`z
When this is all done if you use the '`z' it goes back. I even added that to a key and that worked, it just does not work as part of this sequence. I tried removing the esc (which gets us out of visual mode) but that did not help.

9

Re: Execute Macro for SQL Server

I'll look into it and get back to you, there is no obvious reason why it shouldn't work.

10

Re: Execute Macro for SQL Server

Any update on this?

BTW: This feature is REALLY cool and you should think about adding it to your ads. People are work are envious of my ability to hit a couple keys and have the entire multi-line SQL execute.

11

Re: Execute Macro for SQL Server

Sorry, haven't had the time to look into this. I'll try to push it forward and have some more info in the next few days.

Thanks for the update. I will try to make it more convenient. And also, maybe there is a non-vi product behind this and a few other SSMS-specific features?

12

Re: Execute Macro for SQL Server

Hello Smorley,

I've finally been able to reproduce and investigate it, and then implement a fix. Here is the new build:

  http://www.viemu.com/ViEmuSQL-2.1.27.msi

You need to manually uninstall the previous version before installing this one. If everything's right, it should fix the problem and not create any extra issues. Let me know how it works for you.

Regards,

  Jon

13

Re: Execute Macro for SQL Server

Jon,

Looks good. Just installed and its seems to work. Nice job - that will save me a bunch of work as I'm constantly having to reposition back into the query.

This execute feature is great, I can't tell you how happy I am to have this available. Its almost as good as just having vi available. Thanks for a great product!~

Stephen

14

Re: Execute Macro for SQL Server

Thanks Stephen, glad to hear it works for you. Let me know if anything else acts up. - Jon