Commenting Code in SQL Format
This is about SQL formatted code.
I am using LINQPad 5 Premium Edition v5.43.00
In older versions of LINQPad this used to work for me when I wanted to comment a portion of the code:
I selected the lines, pressed TAB, then pressed CTRL+K+C.
When I pressed the TAB, it indented the section with 1 TAB for each line, and after I pressed CTRL+K+C, it added double dashes in the beginning of those lines, and I was able to run the code ignoring those lines.
But after a recent update, when you press CTRL+K+C, it inserts the double dashes right before the text in those lines, not in the beginning of the lines, so when you try to run it, it gives you an error. I need to manually go to each line and insert spaces after the double dashes and before the text in those lines to separate them.
For example:
In earlier version of LINQPad after TAB, CTRL+K+C it looked like this and ran fine:
It's quite annoying when I need to comment out a longer block of code and I need to edit every single line manually.
Can you please fix it as it was in a previous version? Or is there any other shortcut that would comment a block of text? If would be nice to just use CTRL + slash.
Thanks,
Steven
Comments
I know it is included in the error, but it might be worth highlighting the fact that you are using MySQL as standard SQL doesn't require a space after the double dashes.
Thanks @sgmoore , I didn't know about that. But in a previous version of LINQPad it worked fine, it would be nice to change back the way it was.
No worries - I've got a fix ready for the next build.
The fix is now available in 6.10.8:
https://www.linqpad.net/LINQPad6.aspx#beta
Hi Joe,
I tried version 6.10.8, and it's still the same as I described in my first post. There is no space after the double dashes, and if I press TAB first, then CTRL + K + C, it adds the double dashes right before the commands, not to the beginning of the line.
I'm sorry, it looks like the updated editor assembly didn't in fact make the 6.10.8 build. There will be another build in a day or two with the fix.
Thanks Joe.
Would it be possible to use only CTRL+"/" to commend lines instead of the long combination I had to use in the past: TAB, CTRL+K, C?
Also just another idea: it would be ince if we could switch to multiple cursors like I can do in Sublime Text by pressing CTRL+SHIFT+L. Sometimes I need to lookup a column of IDs, I copy/paste from Excel, but I need to edit my LINQPad script in Sublime Text that allows to quickly edit the whole column if IDs, and inserting apostrophes before and after, and a comma for example in a script like this:
...
where ID in (
'1001',
'1002',
'1003',
...
)
Does pressing Alt+Shift with the arrow keys in LINQPad accomplish this, or are you describing something different?
Hi Joe,
I saw that Alt+Shift + arrow keys don't create multiple cursors as Sublime Text does, it selects a vertical block of text.
I was able to do Alt+Shift + down arrow to create a vertical selection line with 0 selected columns and type apostrophe in the beginning of the lines, but I couldn't find a way to jump to the end of the lines with multiple cursors.
It works only if the lines have the same length, but you cannot do it with variable length lines like:
...
where ID in (
'100',
'1001',
'1002',
'10013',
...
)
There's a new beta now with the SQL commenting fix. You can also press Ctrl+/ to toggle commenting. Let me know how you get along.