-
Jul 17th, 2024, 06:47 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] vs2022, how to comment large blocks of code?. entire subs at once
I have 2 subs, like to just comment all without individually putting single quote on each line
-
Jul 17th, 2024, 06:51 AM
#2
Re: vs2022, how to comment large blocks of code?. entire subs at once
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·
-
Jul 17th, 2024, 07:12 AM
#3
Re: vs2022, how to comment large blocks of code?. entire subs at once
Try selecting the code then press Ctrl-/ (hold the Ctrl key and press /) ... most IDEs use that for block (un)commenting... I know VSCode does it, so I assume Visual Studio will do the same.
-tg
-
Jul 17th, 2024, 07:24 AM
#4
Lively Member
Re: vs2022, how to comment large blocks of code?. entire subs at once
In VS2022 select View > Toolbars > Text Editor.
This toolbar has a comment and uncomment button on it. You can highlight as much of your code as you want and then press the comment button and it will comment it all out at once, and vice versa for uncomment.
If you'd rather use keyboard shortcuts then it is CTRL+K Then CTRL+C to comment out your selected code, and CTRL+K Then CTRL+U to uncomment. You can press K then C or U while holding down control.
-
Jul 17th, 2024, 07:41 AM
#5
Thread Starter
Fanatic Member
Re: vs2022, how to comment large blocks of code?. entire subs at once
Thanks, CTRL+K Then CTRL+C worked
First highlight text then do that.
Useful to me when developing subs, to make changes but keep the old working code just in case.
Then also, I like to keep some code in comments in modules as examples of how to do things.
-
Jul 17th, 2024, 07:49 AM
#6
Re: vs2022, how to comment large blocks of code?. entire subs at once
I use the buttons that themindgoblin showed. The shortcut keys are also pretty nice, but Ctrl+C is always a bit risky, because that's Copy. You aren't as likely to make a mistake with that as you are with Ctrl+P or Ctrl+X, but re-use of Ctrl+ in this fashion can be awkward if you care also copying and pasting.
My usual boring signature: Nothing
-
Jul 17th, 2024, 09:37 AM
#7
Hyperactive Member
Re: vs2022, how to comment large blocks of code?. entire subs at once
Originally Posted by sdowney1
Thanks, CTRL+K Then CTRL+C worked.
Note 1) Remember to uncomment the highlighted section by Ctrl + K then Ctrl + U.
Note 2) Layering comments by re-pressing shortcuts, helps priorized uncommenting and code engaging for dev purposes.
Note 3) Remember to close the thread once you get a proper answer.
peace/.
-
Jul 17th, 2024, 12:48 PM
#8
-
Jul 17th, 2024, 04:09 PM
#9
Thread Starter
Fanatic Member
Re: vs2022, how to comment large blocks of code?. entire subs at once
Thanks, all very helpful.
-
Jul 18th, 2024, 04:26 AM
#10
Re: [RESOLVED] vs2022, how to comment large blocks of code?. entire subs at once
So.
Code:
Dim i As Integer
Dim x As Integer
x = 123
#If 0 Then
i = 2
x = 5
#End If
x = 4
i = 3
I'm testing this and it works better, you don't need to select oceans of code and quote them. Of course makes no sense for a line or two but for more it looks even better than C# /*
Unfortunately I'm more on C# at the company now so that is a really late find, still it simulates a region of commend out code better than quoting everything, you just have to get used to it.
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·
-
Jul 18th, 2024, 05:10 AM
#11
Re: [RESOLVED] vs2022, how to comment large blocks of code?. entire subs at once
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|