In Visual Studio you can use Tab + Tab to automatically create a foreach (or other) structure.
Does VSCode have something similar?
Yes, VSCode does support snippets. They appear in the completion list, and you can insert them by pressing Tab or just Enter. Alternatively, you can use the Insert Snippet command found in the command palette.
The snippet shown in the .gif above is provided by the C# extension.
Related
I downloaded and installed visual studio on my mac to work with xamarin and every time I try to use the text editor I just can't.
This is how the layout looks like:
Visual studio text editor
And this is how it looks like when I use monoDevelop instead:
MonoDevelop text editor
Now, I want to use xamarin and I can't seem to find a solution to the brackets acting they way they do. If anyone can help I would much appriciate it. It's been bothering me for a while now.
It seems like the tabs for C# were not set up correctly within your Visual Studio.
Please try the following:
a) On the 'Tools' menu, click 'Options'.
b) Click 'Text Editor'.
c) Open C# and click 'Tabs'.
d) Make sure that 'Smart' Indentation is selected.
For further information please check out: https://msdn.microsoft.com/en-us/library/999b219z(v=vs.71).aspx
Note
You can automatically let Visual Studio indent your code:
Autoformat selection: Ctrl+K, Ctrl+F
Autoformat document: Ctrl+K, Ctrl+D
When you begin typing a command, for example 'for', the snippet appears in the auto-complete drop down but I can't figure out how to generate the snippet.
I've tried Tab, Space, Enter and double clicking but neither seem to do the trick. Could there be an option in preferences I'm missing?
Is there a way to organize C# usings (remove and sort, in separate or together) via a shortcut in Visual Studio for one or more files of a project?
I know that this can be done via the menu for one file by selecting
Edit > IntelliSense > Organize Usings > Remove and Sort
but I want to do this much faster.
I am using Visual Studio 2013 Express for C# development (wondering how this can be done in older & other versions too though). Thank you in advance.
Since VS2017, it's a builtin shortcut. Simply press Ctrl + R, Ctrl + G. Credit goes to Emanuel Ve, who mentioned this first in the comments; I'm putting the advice into an answer for greater visibility.
Go to Tools => Options => Environment => Keyboard
Enter the key combination you want to use (click the Press shortcut keys: textbox, press your key combo as you would execute it while editing)
Then type "usings" in the Show commands containing: textbox
And now you can assign whichever version of these remove/sort usings commands that you like to the key combination.
This works for pretty much every command in Visual Studio, and from any addons you have installed. Just type a word involved in the command name to find the command. Assign away!
In addition to #Will's answer,
Productivity Power Tools
is a great addon that has all this - and lots lots more!
before i use to see this while adding a new item in VB.NET:
But now from yesterday things are disappeared and i am unable to see them. What i can see is this:
Also when i right click on my project and add Windows Form it shows the same.... the above one
I got the answer :)
Close all instance of Visual Studio. Open visual studio command prompt and type,
devenv /installvstemplates
Press Enter. Let the process be complete and now open visual studio. You will get all missing templates under Visual Studio installed templates.
When u create a new Project, the first will be shown with all items. In Second screen you are just adding a item to the existing project. i.e. Right Clicking on Project, and select Add new Item.
If you want to see that first screen, Right Click on Solution and Select Add New Project
I don't know where is the short-cut button to auto generate namespace import in C# winform/ window store... application, like the Alt+Enter shortcut in NetBean IDE. I and some of my friends have programmed in visual studio for several years but when we need to import library, we have to move the cursor after the Class code and click to show namespace like this:
Thank you for your help :)
Try CTRL+. to open up the quick fix which will give you different options to fix such an error, including adding usings for the correct namespace—if VS finds a valid type in the references.
Ctrl+R and Ctrl+G ... OR Ctrl + R + G
Another little option through the toolbar.