How to triple-slash selected text in Visual Studio 2010 - visual-studio-2010

In Visual Studio 2010 we can Comment selected text via Ctrl+E,C - This prefixes selected lines with the double-slash.
Is there a way to select text and have VS2010 prefix the selected lines with a triple-slash?
For the curious; I am adding XML comments to my c# code. Specifically, I am adding example code within the <example><code></code></example> section of my comments. I'm am building the sample code in a throw-away console app (just to make sure I'm creating code that works). When satisfied with the sample code, I copy/paste it into my app that I'm adding XML Comments to. When I paste the sample code, I have to manually add all the triple-slashes. I'm getting kinda bored doing this, so I'm hoping there is a way I can have VS2010 do this for me.

There is no built-in command to do that, AFAIK.
However, you can do it using VS's built-in advanced text-editing features.
Hold down Alt, select a zero-width column of text at the beginning of the lines, then type ///. This will type into all of the lines simultaneously.
You can select that with the keyboard by pressing Home (as applicable), then repeatedly pressing Alt+Shift+↓.

Related

Visual Studio -> wrap every parameter

Using Visual Studio 2019, I found a really useful refactoring option in 'Quick actions and refactoring':
(might come from PowerTools, whatever)
I just wondered how:
I can make this wrapping settings a default formatting settings
Or apply this formatting on my whole solution at once (without resharper)
For the later, a solution with Visual Studio Code would be perfect as well !
Thanks for your help
You can try using Rewrap extension which formats code, comments, and other text to a given line length (80 by default).
The main Rewrap command is: Rewrap Code / Comment, by default bound to
Alt+Q. Put the text cursor inside a comment line, block or plain text
paragraph and invoke the command to wrap. You can also select just a few lines, or multiple comments in one selection.
There is currently an Open request for this in the VS Code Issue tracker on GitHub

Visual Studio Editor : Always Add new line of code at Ending of existing lines

I am struggling with visual studio editor, I've one WinForm (Visual Studio 2015 Comm) App that I am maintaining from last couple of years, after all the improvements and bug fixes the code behind reached to around 2000 lines.
Issue is If I am adding any new code inside that it places the code anywhere in middle of any other events like If I've added a radio button and want to have click event then if I generate it it places it on 1560th line. (Just an Example).
So Is there any setting for editor that if any new code is getting generated it should always put that on the ending of the existing code like on line 2001?
I am not aware of any such settings but suggestions are needed
Thanks.

Visual Studio 2017: Disable Intellisense for CodeSnippets

I'm using Visual Studio 2017 Enterprise, Version 15.3.3
I looks like IntelliSense has some new features for code completion. On of this feature is, that a field name is automatically suggested when a type is written.
SpacePosition s.. // starting with s, Intellisense suggest "space", "position" and "spacePosition"
I like this feature in general but not for code snippets. Using a code snipped I have the problem, that the name of a literal is automatically replaced by IntelliSense after pressing tab (which is used for navigate to the next literal).
In my example I want to name the property "other" and then jump the the next literal inside the snippet. But because of IntelliSense, the property name is replaced by "spacePosition".
Is there any way to disable the IntelliSense feature inside code snippets?
I found a solution for the same problem in Visual Studio Code:
stackoverflow article but not for Visual Studio
Disable the name suggestions in Tools/Options/TextEditor/C#/IntelliSense. That's what is causing this nonsense. Seems MS realized later that they flipped coders up by adding that feature that changes old behaviour greatly without giving them a way to disable it. Now there is such a checkbox.
I nearly uninstalled this studio because of this lol. Not sure, may be it's a good feature, but i'm too used to Tab code snippets around, that I'm better without it.
How to: Manage Code Snippets
To access the Code Snippets Manager
1.) On the Tools menu, click Code Snippets Manager. Shortcut Ctrl+K,Ctrl+B
How to: Change snippet behavior
To change snippet behavior.
1.) Go to Tools > Options > Text Editor > IntelliSense > Snippet Behavior
2.) See images.
Now there has no such option to disable this intellisense feature inside code snippets, but you can try to click 'Esc' key after type 'other', then click 'Tab' key to jump to next literal, please check the following:
This actually works correctly in Visual Studio 2019 for classes if it is a class that is valid for the current context (i.e. Doesn't exist in a namespace not in the current class namespace or in the using statements for the file).
Here is my example snippet
Snippet Definition
Snippet Use
And here is an example where I use two different classes as the second snippet, one that is a valid class name and works to use tab to autocomplete, and one doesn't work because the class requires adding an additional namespace using statement that is currently missing from the file:
So I see two options.
Use the sucky to cancel any auto-complete logic.
Ensure you have the proper using statements. You can even add using statements to your snippet using the imports declaration:

Folder imported in Code Snippets Manager not showing in text editor - Visual Studio 2010

In the Code Snippet Manager I chose "Language: Visual C#" and added a folder containing one .snippet file I created.
Then, when editing a .cs file, I try to insert a snippet using ctrl+k ctrl+x but my newly added folder does not show in the list.
I'm I missing something? Do you have to specifically tell IntelliSense which snippets you want to have shown in the list when trying to insert a snippet? I thought that was done by choosing "Language: Visual C#" in the Code Snippet Manager...
Thanks!
Does your folder (and the snippet, when you click on the folder) show up in the Code Snippets Manager? If not, then maybe it didn't get added correctly (or VS 2010 didn't parse the snippet successfully, or didn't recognize that the file was a valid snippet)? I believe the folder will only show up in the Code Snippets manager if VS2010 finds something it recognizes as a valid snippet, so if there are any parsing issues, there might be problems.
If the folder does show up correctly, then I also did notice that, when you hit Ctrl-K, Ctrl-X, unlike in Visual Studio 2008, newly added snippet folders appear to be sent to the bottom of the list instead of being sorted. In VS 2008, I was able to stick an underscore before the folder name (e.g. _Code Snippets) and have it show up on top. Not so, here. I realize this might be an idiotic suggestion, but maybe it's at the bottom of the list instead of sorted in with the rest? I know, I know, but I had to ask...
Barring that, maybe there is a caching issue with IntelliSense?
Not much of an answer, I know, but maybe it will jog someone's memory?

Is it possible to copy code from Visual Studio (VB.NET) without indentation?

As I am copying something from within a method, and pasting it into a word document, the code I am copying is already indented. When I paste it I therefore end up with a load of white space next to each line.
I need to copy without this. In C# I can just unindent my code, hit copy, and then indent it back again using the buttons in the IDE. But Visual Basic automatically forces indentation so any attempts to change it don't work.
Visual Studio supports block selection. Press the alt key and drag the cursor to start block selection.
Visual Studio Select Block Text
This is a very useful feature, specially when pasting code here on SO. Visual Studio 2010 will even support multi-line editing using the box selection.
Unfortunately, it seems VB doesn't support the Edit.Advanced.Tabify/Untabify or Increase / Decrease Indent commands.
Here is what you can do:
Go to Tools -> Options -> Text Editor and uncheck "pretty listing (reformatting) of code"
Select the text block you wish to copy without indentation
Go to Edit -> Advanced and click "Delete Horizontal White Space" (or: Ctrl K, Ctrl )
Copy and paste your code in Word.
Turn the "pretty listing" option back on.
the "Delete Horizontal White Space" command will unindent the entire selected text so that there is no tab/whitespace to the left of any line (unlike Block Selection, as prorposed by João Angelo, which will unindent the selected block but keep any indentation within the block).
You may use the Visual Studio extension Copy for review. Besides some formatting, it removes unnecessary whitespace. It works for Visual Basic, among other languages.
Disclosure: I am the author of that extension. Please notify me, if I can improve it to your needs.

Resources