1

Re: Run query in SQL Server Management Studio 2005 with ViEmu

Is there a way to run a query in the Management Studio other than F5?  It would be nice if there were a "vi" way to do it.  Maybe ":exec" or ":run".  Any thoughts on this?

2

Re: Run query in SQL Server Management Studio 2005 with ViEmu

Hi Kirchner,

I've had a look and it seems "Query.Execute" is the command that does it. You can try to use ":vscmd Query.Execute" to run it, it should work. I will add :run as a synonym for that in the next release, which I'm planning to release very shortly (to also fix a small problem in the installer that only affects some installations). I'll let you know as soon as this is ready.

Thanks and best regards,

  Jon

3

Re: Run query in SQL Server Management Studio 2005 with ViEmu

Thank you, Jon.  I appreciate the response.  Some co-workers and I are trying to get our company to purchase some of your software.

4

Re: Run query in SQL Server Management Studio 2005 with ViEmu

Good, thanks a lot. I'll let you know as soon as the new build of ViEmu/SQL is ready (hopefully later today).

5

Re: Run query in SQL Server Management Studio 2005 with ViEmu

I have just uploaded ViEmu/SQL 2.0.59 with the :run command implemented. Details and a link to download here:

  http://forums.ngedit.com/viewtopic.php?id=171

(Uninstall the previous version manually before installing this one)

6

Re: Run query in SQL Server Management Studio 2005 with ViEmu

Is there a way to run just a portion of the SQL editor window? In SSMS, F5 will run just the highlighted text.  Is there a way to 1) highlight text using ViEmu commands, or 2) pass a [range] to :run?

7

Re: Run query in SQL Server Management Studio 2005 with ViEmu

Hello usr01,

If you enable the ViEmu setting "Use standard selection for visual mode" in Tools|ViEmu Settings, it should work like that right away - :run, or actually :'<,'>run which is what will show up, should execute the portion selected in visual mode.

In case you're not familiar with vim's visual mode, you enter it by pressing 'v' or 'V' (better use 'V' for linewise selection), you then move around to highlight the area, and type an operator that will operate on the highlighted area ('d' to delete, 'y' to yank, etc...). It's a great feature of vim. Ctrl-V enters it in column/block mode, which is very useful when editing column-oriented data.

Let me know if it doesn't work fine or more clarification is needed.

Regards,

  Jon

8

Re: Run query in SQL Server Management Studio 2005 with ViEmu

Excellent - I was not aware of visual mode.  Many thanks! 

One other quick question.  I cannot seem to use Ctrl+U to scroll upward in ViEmu.  SSMS intercepts the command and moves focus to the database selection dropdown.  I cannot seem to change this behavior - the ViEmu keyboard management dialog cannot disable the the binding:

1246=SQL Query Editor::Ctrl+U||SQL Query Editor::Alt+D||MDX Query Editor::Ctrl+U||DMX Query Editor::Ctrl+U||XMLA Query Editor::Ctrl+U

This entry appears in both the left (disabled) and right (clashing) lists.  Any suggestions?

9

Re: Run query in SQL Server Management Studio 2005 with ViEmu

Hello,

You are right, the same happens in my installation. I hadn't even noticed the problem because (1) I tend to use Ctrl-F/Ctrl-B rather than Ctrl-D/Ctrl-U for page scrolling, and (2) because it doesn't happen when you are not connected to a database.

The problem is that 'unnamed' commands such as that one (it is apparent because it shows a number in the keybinding list, rather than a name such as Edit.Paste) cannot be programmatically unbound from their assignments.

I'll be investigating it in more detail to try to find a workaround and come back to you as soon as I have more information. I plan to implement a different keypress-interception method in the future (actually, just bringing the one I developed for ViEmu/Word&Outlook into the VS and SQL products) which would fix this, but that will definitely take some time - most likely a few months. I hope to find some workaround before that.

Meanwhile, you can use Ctrl-F/Ctrl-B for scrolling, and you can also map them to get half-page scrolling, by adding this to _viemurc in your user folder (typically C:\Documents and Settings\{username}):

nnoremap <c-f> <c-d>
nnoremap <c-b> <c-u>

Regards,

  Jon

10

Re: Run query in SQL Server Management Studio 2005 with ViEmu

Great, thanks!

11

Re: Run query in SQL Server Management Studio 2005 with ViEmu

There was good stuff in here about how to operate in Management Studio better. Using the "V" command to mark text is a good trick. I wonder if there was a way to make this even easier. One thing I like about Toad is that you can press the "execute current" key and it highlights the "current" statement which is assumed to be all the contiguous non-blank lines around the cursor.  This makes for a great time-saver when you are editing adhoc SQL which may contain many different multi-line statements. Any great suggestions on how to get a block like that quickly marked?

Stephen

12

Re: Run query in SQL Server Management Studio 2005 with ViEmu

Stephen, maybe using V} will work? The '}' motion goes up to the next blank line. If from the bottom, you can use '{'.

If not enough, you can assign some kind of mapping for the feature, to move up, start visual mode, move down, and then run the query (I've used searches for lines with just blanks here, modify by whatever fits best):

:nnoremap <C-S-F8> ?^\s*$<return>jV/^\s*$<return>k:run<return>

You can put this in _viemurc as described above to have it alwway available. And of course, Ctrl-Shift-F8 is just a random choice, use whatever fits you best.