How to rename controls rapidly in Visual Studio 2010? - visual-studio-2010

I´m looking for a way to rename a bunch of controls, which is the fastest way?
Also, is it possible to change the name prefix of the controls to a custom one like so:
| Properties |
(Name) | TextBox1
to:
(Name) | txt1
as default name when inserting the controls on a form?

I think the answer to #2 is "no," that is not possible.
As to a fast way to rename controls, you can go into the text view of the form designer and do an incremental search to move from name to name, so you don't have to click each control and then go back to the property grid.
A bit more intuitive would be to use the Document Outline pane. This is a much faster way to move from control to control and you can rename them in-place instead of going to the property grid. It also has the advantage that you can see by the selection indicator in the designer which control you have selected in the document outline and vice versa.
By default, navigate to View -> Other Windows -> Document Outline.
Here is a screenshot. I know you are using VS2010 and this is VS2012, but it works the same way:

"Replace in Files" which can be found by shift+ctrl+H would be the easiest way to rename all "TextBox" to "txt".
As for the second point, you could either hand-code the controls to use your prefix or write some kind of Visual Studio add-in that would do the translation for you would be the approach I'd take.

Related

Is there any extension to edit Visual Studio (2017/2019) theme colors easily

So, I was wondering if someone knows a program (VS extension) that you can for example, click on a button (aka option), than you select what element (in your code) you want to edit, pick a new color and save it...?
eg. you click on void, it says something like, selected Data Types, and a window to edit color. Or you click on a scroll bar, it says something like, selected scroll bar, and so one..
I was looking for it, but all I can find is basically like "Color picker", "Color theme editor for Visual Studio"...
Even if it's not extension, maybe program or web site...
Thanks in advance.
OK... So there is some way to make it easier, but it's still quite boring / hard / annoying task to do. (Works only with Visual Studio 2019)
Download Visual Studio Color Theme Designer.
You'll need some sort of capturing technique (eg. Snipping Tool - comes with Windows 10).
Launch your VS2019 and capture element/color you want to edit.
Extract the hex value of that color (eg. Paint 3D - comes with Windows 10).
Follow the instructions on VSCTD website (Marketplace) on creating theme and when you're done with opening solution, in "All elements" page, paste the value you got, and to make it easier to search, select "Sort by: Color".
Edit the color you think corresponds to desired element and check if that's the color that you were looking for.
Repeat until you're done.
This method is similar to using Color Theme Editor for Visual Studio 2019, but it gives you option to create automatically some theme and then you edit small parts of it (removes the trouble of editing huge amounts of colors)
You can edit color themes for types of keywords for a language in Visual Studio. For example, I've set mine so that interfaces are a light purple instead of the normal blue.
As far as I know, you can't set the colors for a specific object (like have variable 1 in orange, and variable 2 in gray), but you can set the font colors for code types (so structs are orange, and classes are gray).
You can read more about this here.

Shortcut to surround an html tag by table/row/cell with their closing tags?

Looking for a shortcut in Visual Studio to surround a selected tag by
<table><tr><td>my selected element</td></tr></table>
I am using Visual Studio 2013.
Anything in plain vanilla VS? Web Essentials? Resharper? CodeRush?
CodeRush can certainly solve this issue for you.
Ruben is quite correct. We have a "Surround with Tag" refactoring which can be applied successively with 'td', 'tr' and then 'table' (working from inside out.
Alternatively you could create a template:
Structure only
<table><tr><td>«Caret»</td></tr></table>
This would create the table structure you are after and place your caret ready to enter the data of your choice.
Structure with Paste
<table><tr><td>«Paste»</td></tr></table>
This would create the structure you are after and paste the content of your clipboard inside it.
Existing Template
The built-in .t template will create a much more complex table structure under your guidance, and plugins can be written to address a specific need.
NOTE: These techniques make use of cutting the target element to the clipboard. If your target element is sufficiently complex, this would make selecting and cutting seem like too much work.
However... another CodeRush feature (Smart Cut\Copy) will make this much easier. Simply position the caret immediately to the left of your target and cut. CodeRush will detect that nothing is selected and will dynamically select the logical element to it's right before continuing with the cut operation.
At this point your task becomes
Cut
Invoke template
(Optionally) paste.
All of these steps are invokable using just the keyboard.
If all else fails... :)
If this does not meet your need, please feel free to comment below, or contact me directly (roryb#devexpress.com) and we can discuss your needs in more detail.
I created a new Surround template in Resharper.
<table><tr><td>$SELECTION$$END$</td></tr></table>

VS2012 Text Editor Width

Is it possible to change the width of the text editor in VS2012 - I've got a fairly wide screen and use fairly small text so I end up with a lot wasted real-estate in the middle of my screen.
I don't want to turn off word wrap - I just want the wrap to start further right on the line. If that makes sense!?
You can set this with HTML in Visual Studio 2012 but there is no global setting and it's missing in quite a few languages.
You can just put another "dummy" window next to the one you are writing in, so the actual editor window will be smaller. You can put it on the left if you want to pan the text to the right, and to the right if you want to shorten the lines.
I actually found the answer elsewhere; VS doesn't appear to provide this functionality but Resharper does. Resharper -> Options -> Code Editing -> C# -> Formatting Style -> Line Breaks and Wrapping -> Right margin (columns)
I put mine to 200 which fixed the issue
I know that this is not what you are looking for, but I believe it solves the same problem. I too have a fairly large screen and try to make use of it as optimally as possible.
I hate tabbing between code or design tabs and try to avoid that as much as possible.
VS has a feature that permits the user to create Horizontal or Vertical Tab groups and ever since I have started using it, I have found it very helpful. These options are present in the context menu by right clicking the tab or in the VS Window Menu (Menus are seen only if the tab groups feature is not active).
I have created a screenshot with Vertical Tab Groups created as shown below. In this example, I have a overview of both the designer and the code view at the same time.
We can use tab groups whenever there is a dependency such as comparing code, redesigning a module, etc. I know it takes a little time to get used to this feature but try it out and see :)

Visual studio Reformat Code/Document

I can't find the Reformat button, I know I can use ctrl+k+d, but I wish to have also the toolbar with the button. can someone help me ?
You can use Edit > Advanced > Format Document and you can also move this as a button to any toolbar. Go to Tools > Customize > Commands, select Toolbar and push Add Command button. Then select Edit category and find Document Format.
Apparently VS2010 (maybe others) hide certain commands depending on the style you choose. I chose Web Dev (code) as my choice and the Document Format is not present to be added to a toolbar. But, if I change to C# Code (tools>Import/Export) then the Document Format command is right there in the Edit menu where others here have said it is.
I had to import the C# Dev layout, but unchecked colors and code formatting options (so it won't overwrite those). What section you must import to get the format document button, I don't know, I didn't experiment that deep.
Seems stupid MS chose to force us down specific paths for layout with no convenient way to get out of it.
If you can't find it in the Edit menu: you can also find it if you press CTRL + P and then type >format. The shortcut is SHIFT + ALT + F

Is it possible to hook the copy and paste of Windows Phone Designer and change its behavior?

I like the windows phone 7 designer but the copy and paste of textbox is irritating. It just keep paste the textbox at the very top. It would be much more productive that it paste below the previous textbox.
So would it be possible to change this behavior by hooking this with some IDE API ?
If you are using the visual designer, rather than using copy and paste, you can drag a new control from the toolbox and drop it precisely where on the form you want it.
The IDE isn't arbitrarily dropping the control at the top of the screen, it places it at 0,0. You could argue that this is as good a place to put it as any. In a true copy and paste, the physical location should be exactly the same but that would be confusing.
I would expect it to be quite uncommon to place one textbox directly under another without a textblock or somethign else in between. In any case it would be necessary to change the position from where it was copied. At least with the current behaviour you'll always know where the new control is.
Not sure about hooking into the IDE, but you might find it easier to just use Blend for the UI aspects. For example, if you have a vertical stackpanel, you can copy and paste and have each control appear below each other in the correct position.

Resources