Visual Studio IDE - how to insert snippet on one tab click? - c#

I use Visual Studio IDE for C#. By default, you need to click "Tab" button twice to insert a snippet. Is it possible to insert snippet with only one "Tab"? please suggest me settings or extension.

To answer your question.
No, it is not possible to do that.
But there is a "trick" to make it feel like a TAB.
You hold TAB a little bit longer (but is no longer effetiv as pressing TAB 2 times).

Related

Is there any way to NOT get a Designer error when deleting code? (C#, Visual Studio, WinForms)

I'm making a WinForms program for my Diploma final project using C# and Visual Studio.
Sometimes I accidentally double-click a tool and that opens up the main event for the tool, like button_Click. But when I delete that code and check the Designer, it gives me an error message. If I choose to ignore it, all of the Form's formatting is lost and I have to start over (real pain in the a**).
I usually just click the - to minimise the code block and then add comments that the code is unused. But as you can guess, this makes for a really ugly and unorganised coding page.
Is there any way for me to remove the code and not get a Designer error?
Go to the Form.Designer.cs file or F12 on the InitializeComponent() method.
Then on the right margin look for the red dots and delete the events pointed to methods that have been deleted.
Anyone got a quicker way?

Visual Studio Code Order In AutoCompletion

I recently switched to Visual Studio Code and I love it! It starts so quickly andI just enjoy the open source environment more than Visual Studio. But there's one problem that I have encountered that bothers me more than it should.
Before I could if I wanted to autocomplete the syntax for an if statement I'd just be able to type in "if" and touble tap tab, but now the autocompletion IntelliSense things pop up in the wrong order:
The red box is the wrong one that gets displayed first and the green box is the one I want at the top. My question is if there's a way to configure it so that I get that statement at the top. It's the same with for-loops, foreach-loops and pretty much every other autocompletion that I want to use.
Create snippet (or edit) ctrl+shift+p Preferences: Configure User Snippets
settings (ctrl+,)
"editor.snippetSuggestions": "top",

Visual Studio 2013 Add custom toolbar Button

Hey all I have been searching Google for a while now trying to find anything on how to go about setting up you're own button on the VS toolbar.
What I am talking about is this:
And when I click on that button I would like to be able to execute some C# code.
As an example, say I had the word "HELLO" highlighted and I pushed on that button on the toolbar and I wrote some code behind it that, when pressed, have whatever is highlighted turn bold and change color from normal BLACK to .
I was originally thinking that it was called Visual Studio Extensibility Tools but that doesn't seem to be what I am looking for here - it seemed more as a Nuget plugin type of thing?
I'm looking for more like what you can do with the Office suite of products within VS addins - As in make a button for Outlooks toolbar, etc..
The only remotely close thing I could find so far would be this.
If anyone has done this before or at least know what to search for then please let me know!
You were on the right track with Visual Studio Extensiblilty tools.
There are several steps.
Create the Toolbar and add the button.
Create the event handler that runs when the button is clicked.
Determine what document has focus (c# doc, xml doc, vb doc, etc.)
Determine what is selected in the document.
Change the code formatting
Start with an overview of the Extensions SDK.
Here's how to create a toolbar with the VS extensions.
Creating a Toolbar for the IDE

I can't type '>' in Visual Studio

I am trying to solve problem with typing '>' character in Visual Studio. When I press the key nothing happens. The key works in all other applications, but not in Visual Studio.
I have tried install the Visual Studio 15 (the new test version), but even that didn't work. Any ideas?
Let me guess, you're using a non-English keyboard layout? One that uses AltGr+. for ">"?
The problem seems to be with Visual Studio 2015 Update 2, which creates a key shortcut for the Ctrl+Alt+. key combination. Resetting your settings will not help, since this is now one of the default shortcuts. Reinstalling or repairing your Visual Studio installation similarly won't help.
What you have to do is remove the problematic key shortcut - go to Tools, Options, Environment, Keyboard, search for command "EditorContextMenus.CodeWindow.QuickActionsForPosition". You will notice it's assigned to the Ctrl+Alt+. shortcut. Remove it and your ">" should once again work.
You can reset your Environment Settings as said here
To reset your settings
On the Tools menu, click Import and Export Settings.
On the Welcome to the Import and Export Settings Wizard page, click Reset all settings and then click Next.
If you want to save your current settings combination, click Yes, save my current settings, specify a file name, and then click Next.
—or—
If you want to delete your current settings combination, choose No, just reset settings, overwriting my current settings, and then click Next. This option does not delete default settings, which will still be available the next time you use the wizard.
In Which collection of settings do you want to reset to, select a settings collection from the list.
Click Finish.
The Reset Complete page alerts you to any problems encountered during the reset.
If the above still doesn't works, then follow this:
Press the Alt button from your keyboard and type in 62 from your NUMPAD
Alt + 62
Visual Studio allows you to remap almost any key combination to any command. It's fairly easy to cause havoc by rebinding a commonly used key to something rather innocuous via the Tools > Options dialog:
And given the sheer number of commands VS offers, trying to figure out which command it was bound to is nearly impossible is like searching for a needle in a haystack. The nuclear option is just to reset everything back to factory defaults (I assume that's okay with you since you've tried re-installing). However, if you want a more surgical approach you can manually edit your settings (usually under Documents\Visual Studio <X>\Settings\CurrentSettings.vssettings) and look for a line like this:
<KeyboardShortcuts>
<UserShortcuts>
<Shortcut Command="Window.PinTab" Scope="Global">Shift+.</Shortcut>
</UserShortcuts>
</KeyboardShortcuts>
And just remove it the shortcuts you'd like to get rid of. (You'll probably want to use an editor like Notepad++ that will reformat the XML for you to edit it more nicely). How this happened in the first place isn't clear. Unless you knew about this dialog to begin with, it's hard to see how you could have added this shortcut. I think someone may be playing a trick on you.

How to temporarily disable Visual studio auto generated events?

All,
I have finished the GUI design phase... Now I've started to add meaningful names to all the controls in my application. Visual Studio is driving me nuts auto generating the events each time I click on the control to change its name (ok so it only happens when I mess up and double click... but still annoying).
Is there a way to temporarily disable this feature? I still want it because it is a great short cut when I'm coding.
Thanks!
You can't disable double clicking AFAIK but you can open document outline (Menu View > Other Windows > Document Outline), and rename the controls via F2 in this window. It'll be much faster and will help see easily the visual tree if your form is complex.
afaik there is not. Just be careful with your clicking and if you do mess up CTRL+Z CTRL+Z is your friend :)
If you can recognize which controls are which in code, you could open the .Designer.cs files and rename the controls there with the refactoring tool (right click the control name, Refactor, Rename).
It may or may not be straightforward to recognize which controls are which given that you have used generic names so far, but at least it's an option. Personally, I avoid that situation by immediately assigning meaningful names.
It's not just renaming controls, it's resizing them by dragging that is a bigger problem. CTRL+Z works to remove the auto-generated code but simultaneously undoes the resizing of the control. Very annoying.

Categories

Resources