Request Description
I'd like to set a hotkey to run the query under the current cursor position without having to select all the text. Currently I need to keep highlighting the full query and executing "Run Selected Query". It would be very convenient if I could just place my cursor anywhere in that query and execute "Run Query Under Cursor" or similar. It's a bit tedious to keep highlighting the query I want to run.
Most of the time executing the full file is overkill on my large database because I use the sql file as a scratchpad to build complex queries and try many different things.
I understand looking for the beginning and end of the query may be difficult to get right. Maybe for starters something as simple as looking for the previous semicolon or beginning of file and the next semicolon or eof.
Describe alternatives you've considered
It looks like there are currently three ways to run a query (unless I'm mistaken)..
Related or merged into:
https://github.com/mtxr/vscode-sqltools/issues/363
https://github.com/mtxr/vscode-sqltools/issues/354
What toad for oracle does for figuring out the current query is looking at blank lines. It gets your cursor position, finds the previous blank line, next blank line and everything between those is the current query. That would be fairly easy to implement I guess
So I implemented this and a bunch of other stuff. Please see my pull request
@mtxr would love to see this implemented. Looking at #293 it looks like the contributor stopped responding to your questions, so the PR was closed. Can I take a crack at it? Was thinking of just adding the "Run Current Query" part out of that PR since the PR was so large.
@johndevedu please go ahead! I'll be happy to accept your PR.
Just giving you more tools to work, @dnlw07 send me some instructions he thought could be useful.
Regarding the ‘Run query under cursor’ I have a regex script which can help you with that.
It’s JavaScript regex flavor:
((.\n)|.)+?;|(?<=;)((.\n)|.)+
It is multiline script, so if you paste this script directly into VSCode, it will select all SQL scripts separated by semicolon (including boundaries).
Let me know if you need any help, I'll be happy assisting you
@johndevedu any luck?
I'm interested in this as well. I support the idea of splitting on semicolons with a regex. I've extracted the Run Current Query command out of the original branch by @vrokolos and tried changing it, starting with b3d0110e747280d8ac74d6b68c8de06b0da8c750. I'm going to test it over the next couple of weeks and open PR if successful.
Thanks @steg0
My current approach is https://github.com/mtxr/vscode-sqltools/pull/481. (I opened it against v0.21.x -- sorry for that -- haven't caught up with master yet.)
I opened https://github.com/mtxr/vscode-sqltools/pull/482 against master now and closed the other one. v0.21.x is for bugfixing I guess after all. Sorry for the noise.
added some extra feature to your PR @steg0!

Thanks to you and to @vrokolos it's being closed.
Oh wow just tried it, that's definitely nifty. (Let's hope the splitter is fast enough to not cause lag in larger files :-P )
Hey @mtxr , @steg0 , can you please guide how to get these 2 features work?
I haven't figured out how to get this working either. Not sure what I am missing.
From the PR, it looks like the command should be "Run Current Query." But I do not see that in my VSCode commands list yet. Maybe this version was not yet released? It looks like the changes for this went in around Jan 19, but the latest release is v0.21.6 from Jan 3. -- But looking in VSCode, I somehow have 0.21.7 installed. ¯\_(ツ)_/¯
This note makes it sound like the enhancement will be in version 0.22. https://github.com/mtxr/vscode-sqltools/issues/492
you're right, it's not released and only in master. I would hope it gets released with the next major upgrade.