This is my first question on stackoverflow, so here goes:
I've got this annoying problem/feature in Visual Studio 2015. The problem is every time I create an if statement, for, while, etc. with autocomplete (tab-tab). When I then go to the line of the end bracket and try to create a new line (simple press of Enter) right after it, my text cursor will immediately jump into the brackets, instead of making a new line.
I've looked far an wide as for trying to disable this "feature" as it is incredibly annoying. But I have not been able to find any information on it anywhere, so now I am asking you all this question.
Thank you!
How I produce the problem:
Anywhere in a C# project, make a new if statement (while, for, etc. can be used too).
Navigate to just after the end bracket.
Press Enter to make a new line.
The marker will have jumped to the inside of the statement, instead of making a new line.
The 'problem' is that when using the tab key you are activating the snippets feature. After typing tab you are in 'snippet editing' mode, where each tab (and shift + tab) are used to navigate the placeholders defined by the snippet. In snippet mode, the Enter key always takes you wherever the person who designed the snippet thought it was the best place to leave the cursor after that snippet. For the if snippet that happens to be inside the brackets.
The good news is that you can create your own snippets, and even modify existing snippets to change their behaviour. However, as far as I know this involves manually editing snippet definition files (xml files) or using external extensions. For example: http://blogs.msdn.com/b/visualstudio/archive/2014/01/15/visually-creating-snippets.aspx
As a workaround, you can also just press Esc to exit snippet editing mode before pressing Enter.
Related
So I didn't use to have this issue as much in older versions, and it even then it was easy to get used to, but i got VS 2019 recently and now when I write code it'll randomly autocomplete half way in and add shit I didn't write WHILE IM STILL WRITING. I don't press enter, I don't click on anything, it'll just add what it thinks I want without any confirmation.
I tried searching how to disable this, but I only ever find how to turn off intellisense recommendations altogether (Tools > Options > Text Editor > C# > IntelliSense). I don't want to disable the completion list from showing up, I WANT intellisense, I just want it to let me code without inserting new code on it's own. Just show me recommendations, don't automatically add them in for me without any input from me.
Edit -> Intellisense -> Switch Between Automatic and Tab-Only IntelliSense Completion
Had the same problem, this worked for me.
I think you want to disable the IntelliCode. you can do it by
Choose Extensions > Manage Extensions, find and select the IntelliCode
extension, and then click Disable
I was running into this same issue with Visual Studio Community using C# and Resharper on a fresh installation.
This seems to occur on writing invalid syntax, Visual Studio replaces whatever is written with it's closest valid guess when the user presses space. Specifically I was typing in a variable without declaring a type first.
output // gets overwritten automatically with XmlOutputMethod
var output // does not get overwritten automatically
Unfortunately, I do not know how to disable this feature in Visual Studio. Hopefully this information is of some use.
I've recorded a short video of my text being overwritten by Visual Studio, which can be found here
I am learning to write in C# on Visual Studios and everything has been going well until today when i was trying to run my app
(using Ctrl + F5). After I tried to run my app it would not run and prompted me to save. Unfortunately I did not pay to much attention and tried to save it but an error message came up saying something like, "There already exists a file named form1.designer. Would you like to replace this file?" I was worried to replace the file so I saved it in a new location.Now when I
look at my solution explorer my original form1.designer.cs is not usable and a new form1.designer has been added.
I am no longer able to go to design view where i can edit the GUI(when i use form1.designer.cs), when i do it displays a blank form. When i try to open my design view from the lower form1.designer, it takes me to the code where the Components are initialize. The program still works perfectly when i run it, i just can't edit the GUI.
I figured it out, it was a linking problem between the form and the design GUI. I had to right click on the solution, click add, existing item, and then i had to select the item i wanted to link. In this case it was the ".cs" file.
I am working with the new asp.net core 1.0 framework on Visual Studio Code.
My question is, how do I traverse through all the overloads a method might have?
When at that stage you can just press ( and it will prompt you for the overloads.
Take this example:
I press ( and I get:
If I happen to change focus, I can go back into the call at this.M1( and press Ctrl+Shift+Space (or ⌘+Shift+Space on macOS) to get the overload prompt again:
Pretty much the same as Visual Studio.
This is in VS Code 1.7.1, C# 1.4.1 extension.
I can't comment on the accepted answer but in case anyone has the problem Dawson B mentioned, where you can't navigate the little window of overloads with the vim extension enabled, I found a solution. It was difficult to figure out what that window is called as it's not easy to google, but it is apparently a ParameterHint.
Open the Keyboard Shortcuts with Ctrl+K Ctrl+S, search for "hint", click the pencil to the left of showNextParameterHint, change to Alt+N, and showPrevParameterHint to Alt+P, to not interfere with the Ctrl+N/P binding to Intellisense suggestion navigation. Of course if these conflict with some other extension/custom binding you have, pick whatever works best.
So, I made a program in Visual C# 2010 Express. Finished enough to work, and pretty darned good for my first attempt at the language. But then I foolishly decided, "Hey, this program needs a close confirmation dialog before I send it out!" So I write the function, and then I go into the auto-generated code to bind said function appropriately.
KABOOM!
Now, the form designer shows a blank form, and all those shiny components have all been erased from both the designer and the auto-generated code. Which, in such a simple program, is about 80% of the work I put into it.
Now, in NetBeans, I would right-click the file's tab, and just go back to a previous version, maybe losing about 15 minutes of work. This is a pretty obvious concept, I'm just not sure where to find file history in Visual Studio. So, where is the equivalent so I can get my work back?
(I've also managed to get my code back by just undoing a whole bunch - but the designer doesn't see it, and neither does the compiler, so it still builds to a blank form.)
Sadly, you've just learned a couple of things.
One is to never, ever modify designer-generated code. In fact, C# has a concept called partial classes which allow you to modify a generated class without having to modify the generated file.
Second, that Visual Studio in and of itself has no built in source code control -- you need to choose the one you like and be diligent in using it. Some of the most popular are git, subversion, mercurial, and Team Foundation Server. I personally use svn, but the others are good too. Avoid something called Visual SourceSafe (VSS).
From the sound of it, I'd say you tried ctrl-z until some point in your code, but not in the designer?
Performing multiple "undo's" in the code-behind file where you put your code is one thing, performing "undo's" in the designer is another.
Hopefully, you have not closed visual studio yet, and viewing your now blank form in design view, and trying a bunch of ctrl-z presses there, might do the trick.
Actually the controls are not lost from Design code or Initialize
Component() ,make sure that whether check
Initialize Component() { this.controls.add("Where the control was ")
}
Example:
1-this.Controls.Add(this.panel1.label1); 2-this.Controls.Add(this.panel1.label2);
either in form you can write like below
should write in the Initialize Component()
this.Controls.Add(this.label1);
I had a similar effect: the code wasn't lost because the project compiled perfectly but I only got a blank form in designer.
This was because the form was inherited from another form, and I added in the Load event of the base form the line: this.MdiParent = Application.OpenForms("BaseForm");
After deleting this line (and recompiling) I could access the design of the descendig forms again.
One thing you could do, it won't help you this time, but may be a good idea for the future - if you copy your code alot (like I do), get one of those clipboard savers - like ClipTrap (which is lightweight, simple, and great).
Then, if you realize you can't undo what you did, then you get a second chance by running through the "trapped" text to see if what you want might just be there.
Another good option is to try something like AutoVer, which will save a copy of any changed file (or files in a folder) every so often as you like. This could provide you with a backup of your codefile, or even the entire project - every five minutes, or every minute as long as something has been changed. Awesome program. This is a certain fashion of source control, or at least source backup.
(And no I'm not the authour of either application)
However, for your particular problem, if the code is still there in your designer.cs page - maybe you just erased a reference or a namespace. Make sure the namespace matches, and make sure your in your form's code file, that the InitializeComponent(); function is being called (that's what places all the designer's controls onto the form, you know).
In the code behind file click 'undo', not in the designer window. Accept the warning, and when the code comes back, the form should be back to normal, Visual Studio 2015.
OK, this is a silly question, but when using Visual Studio, if I am writing XML doc comments in Visual Basic, I can use the tab key to switch between fields (e.g. Summary to Param to Returns). In C#, however, hitting the Tab key inserts a Tab, so I have to click on the individual fields to navigate to them (or use the arrow keys). This makes what should have been a simple process tedious and time-consuming.
Anybody know if there is a default keyboard shortcut I can use, or if there is a specific command I can map to an unused keyboard shortcut? I am using Visual Studio 2010, with ReSharper 6.1. Did some searching in the SO archives, but either nobody else has this problem, or I don't know the right keywords to ask (the latter is much more likely). Thanks in advance!
EDIT: I should clarify, a bit. The tabbing behavior in VB is native to Visual Studio 2010; the ReSharper install is fairly recent (after I switched to C#), and I wanted to mention it in case someone might know whether ReSharper had added their own navigation shortcuts (as they have tons) for this. Thanks again!
Resharper does have the possibility for structural navigation. Normally you can use the Tab or Shift+Tab Shortcut to the next or previous code element.
If your cursor is in a code element (i.e. not in the whitespace region before a code line) the Tab Key shouldn't insert a tab but navigate to the next section.
Configuration of the structural navigation can be done in Environment|Editor|Editor Behaviour.
If it's still not working as described I'd try to reset the settings (especially those for Resharper) and check wether Resharper is installed properly.
I might be misunderstanding the question, but maybe it sounds like you can just reset your user settings? http://msdn.microsoft.com/en-us/library/ms247075%28v=vs.100%29.aspx ? Or just run a devenv / resetuserdata . Do that, and when you start up visual studio, maybe choose the 'general' settings rather than the C# or vb.net specific ones?