Where is the option in Visual Studio 2019 to have Ctrl-K Ctrl-D not make stylistic changes to VB.NET code? - vb.net

When I press Ctrl-K Ctrl-D, Visual Studio formats my VB.NET code, same as it does with C#, but it also makes some other changes that I'd like to disable because they are making it hard to see actual changes in source control. For instance, it adds parentheses after method calls:
connection.Close
becomes
connection.Close()
and spaces are added around operators:
"answer is "&42
becomes
"answer is " & 42
There's got to be some option to disable these changes but I'm having trouble finding it...

In Visual Studio, the code of VB.net is automatically formatted by default. If you want to cancel the automatic formatting, taking Visual Studio 2017 as an example, you can change the settings as follows.
If you write code after that, the code will not be automatically formatted.
As for Ctrl-K Ctrl-D, you can disable them in the following steps:

Related

Visual Studio Intellisense constantly popping up

Using VB.NET in Visual Studio 2019. Type a single space character anywhere in the codebase and a popup displays a long list of options. You have to constantly click away or press ESC. This quickly gets annoying.
Tools > Options > Text Editor > Basic > General > Auto list members stops these unwelcome popups...but now "member of" functions are not listed at all! For example:
Dim test As String = "fred"
test. ' Nothing is displayed when the dot is typed, but expected `Length`, etc
Is it possible to get Intellisense for "member of" only, but otherwise switched off and no other automatic listing (so nothing would be displayed when you are just typing away).
What a shambles to do so much with a single setting. If someone from Microsoft is reading this, check out how Borland's Delphi 7 handled this...an IDE of speed and beauty.
Very annoying that it distracts you that much. Im sorry to hear that.
Unfortunately, the final answer is that it cannot be solved, because microsoft would never consider an unpopular opinion.
The 'popup' is one of the most important features why people moved away from notepad in the first place. Every IDE will have it, and if they dont, they soon might. it is rarely unwelcomed.
With that in mind, microsoft didnt intend visual studio to be used without it.

Visual Studio 2013 - F10 / F11 stopped working on upgrade?

I just upgraded my Visual Studio from 2012 to 2013 and haven't done anything else yet short of installing all the updates recommended.
For whatever reason, when I go into my solution and press F10 or F11, it runs the entire program as if I had pressed F5... F8 works the way F10 used to, but I don't know why the keys I've always used now don't.
I set up visual studio as a VB environment.
How can I fix this?
Thanks!!!
Additional Info:
Just to add on as much information as I can, if I set a breakpoint in my code, then I can use F10 / F11 to continue stepping through my code once the breakpoint is hit and execution is stopped as would be expected.
EDIT 2013-12-31:
Based upon a comment made by Neolisk, it appears this is simply a change in default behavior in Visual Studio 2013... If anyone knows how to change this back to the way it was in 2012, that would be GREATLY appreciated, but at least I now know it's not an error / installation issue.
If 2013 works the same as previous versions, then do the following:
Navigate to Tools > Import and Export Settings
Choose "Import selected environment settings"
On the next screen, choose to save your current setings if you want to.
When you get to the point where you can import, just select "General Development Settings"
That should set everything back to what you're probably used to. Most people are set up using general settings and either don't realize it or just forget.
EDIT: If your issue is that the program executes when you press F10 or F11 when you are not debugging, then I think you might be out of luck. It's done that to me personally since VS 2008 (I'll frequently miss the F12 key when I'm in a hurry), and, after some searching, I think it actually happens to everyone:
Visual Studio - Prevent F11 from starting the debugger?
My guess is that this is a side-effect of not being able to set contextual hot keys based on whether you are or are not debugging. Since F10 and F11 are tied to debug-execution-related operations, my guess is that Visual Studio realizes that it needs to be debugging to process them, and thus starts the program.
ANOTHER EDIT: Of course, it's also possible that you had the scheme set to something else entirely in VS2012. Check out all of Visual Studio's pre-defined hotkeys by environment here: http://msdn.microsoft.com/en-us/library/da5kh0wa(v=vs.120).aspx
If none of those have the mappings that you're used to for F8, F10, or F11, then it's possible that you or an add-on may have had few custom hotkeys defined.
Worst-case scenario, you can simply redefine your shortcuts manually by key in the keyboard settings: Tools > Options > Environment > Keyboard
It sounds like you are in VB settings and not C#. You should try changing your settings to one or the other and see if those debug options change. On my machine
Tools - Import Export Settings - Reset All Settings - C# (If you want F10/F11) VB if you want F8/Shift-F8. It doesn't matter what your settings are you can still code in both languages, but if you are used to pressing F10 to debug VB.NET code you've been using C# settings this whole time. Nothing new with Visual Studio in this regard. I am using VS2013 Ultimate, have been using Visual Studio since VS2003.
The first image is VB.net, second is C# settings
You can try some of these reset settings:
And different combinations thereof, i.e. ResetToBasic first. If does not help, try ResetToC#, then back to Basic. Then try General, back to Basic. See if you can hack your way through like this.
EDIT: I tried my VS 2012, and compared to VS 2013. What you described is completely normal. VS 2012 used to step in Form_Load and similar on F10 and F11, VS 2013 no longer does it. So it seems like your VS 2013 is working as expected.
Microsoft probably has a reason to not allow to step into a property by default.
Properties are supposed to be mostly get and set and not contain a whole lot of implementation in it. But that may not be the case all the time.
If somebody is trying to step into a property that means this developer is suspecting something in that property that may be causing problems. So by default this behavior needs to be reversed and allow stepping into properties.
For now this is how you can enable stepping into properties.
Go to Tools > Options menu in Visual Studio.
Goto Debugging > General menu item in left pane.
In right view you will see and option Step over properties and operators (Managed only). Uncheck this option and then you are all set.
Enable step into properties in Visual Studio Debugger
If the above didn't work then follow this
In the Options.Keyboard page, please select "Debug.StepOver" from the command listbox, and then put focus to the "Press shortcut keys" textbox and press F10, click Assign button to re-assign shortcut, does it work?
You can also try to run Visual Studio under safe mode, which will prevents all third-party VSPackages from loading when Visual Studio starts; if the issue disappear under safe mode, you may consider checking your installed add-ons or VSPackages.
Second, to log all activity of Visual Studio to a log file for further troubleshooting, please use the /Log switch, and post the log file content here, so we can do more investigation on it.
If this feature works well before, and suddenly behave abnormally, it usually indicate that some files or configurations of Visual Studio installation is corrupted or missed, you can:
Restores Visual Studio default settings by using "Devenv.exe /ResetSettings" command. Please backup your settings before restore to default settings.
Repair/reinstall Visual Studio;
To repair Visual Studio In the Add or Remove Programs dialog box, select Visual Studio then click Change/Remove.
I found I had to run VS as Administrator to debug properly. I also do a clean solution prior to debugging, especially on x64 machines. If you put a manual debug breakpoint in the code and the IDE indicates it can't stop at that point, then it's possible that the debugger is out of sync with the source code.
An idea to test it in a short way:
Create a Hello World console app.
1 Module Module1
2
3 Sub Main()
4 Console.WriteLine("Hello")
5 End Sub
6
7 End Module
Build first.
Put the cursor in line 4 (before each step), commands should start Debug Mode if you are in Design Mode.
F10 (StepOver): Should break on line 3
F11 (StepInto): Should break on line 3
CTRL+F10 (RunToCursor): Should break on line 4
If it is working properly: Maybe the assembly which containing the entry point of your program had modified and wasn't been rebuilded, or there is somthing other problem with the point where the control expected to break.
If it doesn't work as expected on the sample, I think you should ask on MSDN FORUM or make a bug report.
I don't know why they might have intent to change this behavior.
It is working for me in my 2013 Express Edition with C# recently.
I found what I think is an acceptable workaround for the non-functioning F10/F11 Keys. They are probably the most used keys in stepping through code, and it is a real pain to click on debug and select the key from the dropdown.
I got around this shortcoming by adding icons to the toolbar for these operations.
If you are not sure how to do this, On the Debug toolbar click on the down pointing arrow near the right side of the bar. Click on Add or remove buttons.
Select Customize...
Select Add Command
Select Debug
Scroll down to the desired key (Step over / Step into)
You once clicked, you will see the two icons added at the left side
of the toolbar, Unfortunately they are the same Icon, but with a
little use, you should be able to select the right key to click on.
I actually prefer this method to trying to remember which function key
to press.
On many branded laptops, there is an extra button "Fn", Press "Fn" and "Esc" together. Functional keys will be enabled in visual studio.
Kindly press Fn key and Esc (with Lock with Fn label).
Sometimes it gets locked and Media Player buttons get activated.
Sounds stupid to ask but what type of keyboard do you have? I know some keyboards have different modes that allow you to set different profiles for keys based upon the application. I use the feature with my Microsoft Natural keyboard. However I have had problems with the profile still being active when I switch into Visual Studio and then F10, etc doesn't work correctly.
I faced the problem that F10/F11 doesn't work but the breakpoint works.
Once I uninstall the Security Software and unload the relevant drives it works again.
So my advice is that. And I guess it's due to the drives, so if these don't work just try to unload those questionable drives may connected with this question.
Using Logitech MX 3000 Keyboard, I've upgraded to the last setpoint version and these keys work now perfectly. (Driver version 5.90.41)

How do I output code while debugging in Visual Basic 2010?

When I'm debugging my application something is not right, and I can't continue.
So is it possible to see the output code of my app while I'm testing it to see what is wrong?
I open the output window but nothing happens in there it's just stay blank.
In two words: I want to see what my app is actually doing while I'm testing it.
I'm using Visual Studio 2010.
So is it possible to see the output code of my app while im testing it to see what is wrong?
Yes, but you actually have to output something, otherwise nothing will show up. In VB.NET (which is the language you're using if you have Visual Studio 2010), this is accomplished with the following code:
Debug.Print("Here is some text that will be output.")
The documentation for the Debug.Print method is here. In order to call it like that, you will also have to have imported the System.Diagnostics namespace. You do so by placing the following line at the top of your code file (with all the other statements that look like it):
Imports System.Diagnostics
The output will automatically appear in the Output Window. If you still don't see anything, ensure that output is not being redirected to the Immediate Window instead: Tools -> Options -> Debugging -> General -> uncheck the option "Redirect all Output Window text to the Immediate Window".
Confusingly, you use the word "code" in your question, saying that you wish to "see the output code of [your] app while testing it". I'm not sure if by "code" you actually mean "output", in which case the solution above will work for you.
If you actually mean code, as in your program's source code, then you can use the Break toolbar button (or press Ctrl+Break) in the IDE to pause the execution of your program. This will automatically dump you back into the code editor with the currently-executing line of code highlighted.
Visual Studio has some very powerful debugging tools. If you don't already have a general idea of how to use them, I strongly recommend picking up a book on either it or VB 2010 that will teach these things to you. They can be very confusing to learn by trial and error, but are not all that difficult if you have a good guide. Spend that time debugging your code, not figuring out how to use the IDE.

VS 2010 adding spaces at line end in AssemblyInfo.vb

I'm working in VB in Visual Studio 2010, trying to keep the lines in my AssemblyInfo.vb file clear of extra whitespace at the end. I track my projects with git using GitHub's Windows client and the powershell environment it ships with, so when I do a git diff I get red marks wherever there's erroneous whitespace.
Basically what I've found is that if I remove the whitespace in Visual Studio and save the file, it comes back. If I remove it in Notepad++, save, and reopen it in Visual Studio, the whitespace stays gone. After that, as soon as I change anything on a line, Visual Studio adds a space to the end of each line that I've changed which happens to end with > otherwise. If I change the end of the tag to />, it doesn't add the space, but of course that doesn't compile.
I've dug through the Text Editor settings for Basic, XML, and All Languages, but don't see any setting specific to this. Is there one I'm missing, or should I plan on using notepad for version changes? I'll also mention that I have Visual Studio 2012 on my personal machine, and it doesn't seem to do this there.
Is there any reason why you cannot use project properties?
Ah, found it. For future reference, it's part of "Pretty listing (reformatting) of code" in Text Editor > Basic > VB Specific. Thought I had that turned off already.

Disabling Intellisense Auto Line Return [duplicate]

When editing C# code in Visual Studio 2010, the ENTER key makes IntelliSense complete the current suggestion, without adding a new line.
In VB.NET, the default IntelliSense behavior for the ENTER key is to add a new line after completing the current suggestion.
How can I configure IntelliSense to change the VB.NET behavior to the C# one?
I already know that I could press TAB or SPACE, but out of habit I always end up hitting ENTER (and changing line).
UPDATE VISUAL STUDIO 2017:
Now with Visual Studio 2017 you can change it. Tools -> Options -> Text Editor -> Basic -> IntelliSense.
In Enter key behavior select Never add new line on enter
ANSWER FOR VISUAL STUDIO 2015 AND PREVIOUS:
If you want to avoid inserting new line on enter with autocomplete suggestion, just don't press enter. Instead of Enter press Space bar which completes your autofill and just inserts a space.
Or you may use this third party app:
Resharper makes it possible overriding Visual Studio intellisense and using its own intellisense. It is the only way I've found.
It has a 30 days free trial if you want to test it.
Unfortunately the set of trigger keys for intellisense completion is not a configurable item for VB.Net. There is no way in the default Visual Studio environment to change this behavior.
It would be possible to develop a plugin of sorts to accomplish this. However that's a pretty extreme measure.
EDIT
As of Visual Studio 2017, it is now possible to change this. See the answer below