Generating code snippets in Visual Studio MacOS - c#

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?

Related

Code snippet shortcuts not working with Visual Studio 2019 and Intellisense

When using Intellisennse with Visual Studio 2019 (C#) it doesn't show shortcuts anymore for my code snippets. I tried enabling Intellisense include all snippets option, but still code snippet shortcuts are not working. Any solutions for enabling shortcuts again in Visual studio?
You mentioned "my code snippets", so I suppose you used the customized code snippets.
Please check these aspects:
1). In Visual Studio 2019 > Tools > Options > Text Editor > C# > IntelliSense > Snippets behavior, and make sure that you didn't select Never include snippets option by accident.
2). Make sure you have added related codes to your customized code snippet file(.snippet).
<Shortcut>XXXX</Shortcut>
And make sure that you have imported the customized code snippet file into the related folder/VS(remember to re-import(override) it if you changed some codes of .snippet file, and remember to choose the Language for CSharp).
If you indeed imported the file, the snippet file will be located in for example C:\Users\Administrator\Documents\Visual Studio 2019\Code Snippets\Visual C#\My Code Snippets, you can check if it exists.
3). For using code snippet shortcuts, remember to press "Tab" key twice(once for Visual Basic, twice for C#) after you type the shortcut. For example, type XXXX in one new code line, and press "Tab" twice, and then the code snippet will be inserted.
Besides, there are some other troubleshooting suggestions, such as repairing VS, reset VS settings, you can also have a try. And I'm not sure if Resharper Extension or other extensions which you installed cause this issue, perhaps you can try to disable it and test again.
BTW, if you mean the default keyboard shortcut key for inserting/surrounding code snippets doesn't work, please check this > Tools > Options > Environment > Keyboard > Press shortcut keys > and make sure, the shortcut keys have been assigned(Ctrl + K/X => Edit.InsertSnippet, Ctrl + K/S => Edit.SurroundWith).

How do I display clean output in Visual studio code with out path or "You may only use..." disclaimer?

I have this simple code in Visual Studio Code
class Program
{
static void Main()
{
Console.WriteLine("Hello!!!");
}
}
All I want to do is get the same result as when I type DOTNET RUN which prints a simple "Hello!!!" to the terminal.
Instead, if i configure it to use the terminal, I get this PATH in blue or if I try to use the debug window, I get this "You may only use..." disclaimer.
How can I set my configuration to either use one of these windows by clicking "Start with out debugging" (not via typing dotnet run manually) to print my output with out any excess info in the red boxes as seen in the images?
If there's a way to configure "dotnet run" in my settings, i'm good with that too so long the output is just "Helloo!!!" on either the debug or terminal window.
You might be able to do this by using an extension like Code Runner which works with Visual Studio Code, it is similar to Script Runner which works with the Atom editor. These are useful for reviewing simple code changes in real-time.
For Python i tried the method below.
In Visual Studio Code, click on the file and then click “RUN” at the top. find “Add Configuration” button on the menu and create a launch.json file by clicking on it. In the file, you will the line ”console”: integratedTerminal . Now change it to “console”:internalConsole. Open your code file and click “RUN” at the top again. Finally if you click on “Run without debugging” button, the output of your code will be display in “Debug Console” at where the terminal is.
Hope it works for you too.

VisualStudio curly brackets won't indent macos

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

Whats the equivalent of TAB +TAB in Visual Studio Code VSCode

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.

Can't invoke snippets through their shortcuts

Being New to Visual Studio 2013 Premium, I don't find any code snippets appearing in the IntelliSense help. I do notice a Code Snippets Manager.
Without using any Resharper tools, or Add Ins, can I get back the same shortcuts in Visual Basic and C# files?
Basically I'm saying that
ctor, Tab, Tab isn't available, nor is prop, Tab, Tab.
New Update:
Works On CS files but not for VB files. Is there a setting I might have to tweak from the code snippet manager?
Maybe the shortcut naming differences throwing you off?
In VB the built in snippet for a property is property (tab) (tab). I don't believe there is a snippet for a constructor in VB since "Sub New" (enter) gets the job done.
You should be able to right click and select insert snippet to navigate the built in VB snippet options and see the shortcuts associated.

Categories

Resources