Changing all elements of highligthed type in visual studio - visual-studio

I use the Productivity Power Tools which highlights all the corresponding elements that are the same as the one being highlighted. As shown below ( "col-sm-6" - purple highlight )
(I think it is Productivity Power Tools doing this. I installed it the same time i upgraded to 2013 , not sure if it is a default setting now)
What I would really like to be able to do is to change all the elements that are highlighted at the same time. So if i want to change "col-sm-6" to "col-sm-4" I want to be able to just hold down a shortcut key which will change all items highlighted.
I have a very strong feeling that this functionality exists.
It seems a lot like the functionality used when you select multiply lines while holding "alt" and then typing.
I have searched around, but cannot seem to find a shortcut for this. I could just do a copy and replace but it would be a lot easier to just hold down "ctrl" while typing.

Yes, it does already exist. If you change a variable name, all the other instances can be renamed at same time (see below). Moment you change the name, a small red bar will be seen below the name -> press Ctrl and click on that bar; it will ask you to change all other instances.
Also, for highlighting a text; there is already a extension ti visual studio present, see here http://visualstudiogallery.msdn.microsoft.com/4b92b6ad-f563-4705-8f7b-7f85ba3cc6bb

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.

Visual Studio column selection - Select by word, not square

This seems like something I would have found hundreds of topics on. Yet I didn't find a single one. I wonder if no one cares or if I just overlooked something obvious.
In Visual Studio when you select a column and want to select the word your cursor is at in each line, when you do CtrlShift+(ARROW KEY), then it doesn't select by word as it SHOULD, but instead it selects a square.
BAD BEHAVIOUR (which VS has):
GOOD BEHAVIOUR (which would be expected, and is in every other IDE):
The Visual Studio ALT select is rendered useless in half the cases, actually in every case where you don't have the "coordinates" precisely the same on every line.
EDIT
I seem to have to explain why the VS behavior is bad, people apparently consider it ok. So the problem is that when you column select in VS, and you have it exactly like in the example, or even without tabs, you'd copy some =, though they won't be everywhere.
If you select a column like VS Code or JetBrains has it, you'll just copy WHAT IS NEEDED and that OBVIOUSLY being just the words in the column.
I have a solution for you, but you may not like it. It's using the new Multi-Caret Support in Visual Studio 2017.
Here is my example code where I want to copy only the property names (sorry for lack of inline images):
Multi-Caret Code Example
Using Ctrl + Alt + Click to click and add a caret to the end of each word. (If you screw up and click somewhere you didn't mean, like I do many times, then reclick to remove that caret and click on the correct spot.)
Multi-Caret End of Line
Now hold Ctrl + Shift and hit the ← Left Arrow. This will select to the beginning of the current word on each line.
Multi-Caret Word Selected
Copy/paste as you wish

Does Visual Studio or Resharper have an auto-completion overwrite feature similar to Eclipse?

Sometimes I'll have classes/methods/variables with similar naming. For example, GetABar() and GetAFooWithABar() (assuming for the sake of example that these aren't horrible names to begin with).
I get into situations where I want to change one of the calls from the former to the latter, and when I start typing in the middle of the name, I'll get an auto-complete suggestion. If I select the suggestion, the following results:
GetAFooWithABarABar()
In Eclipse, there's a handy feature called completion overwrite which you can set as a default, or select on the fly by holding down Ctrl when you select the suggested term. Does Visual Studio or Resharper have a similar feature?
In ReSharper, you get a different result if you complete with Enter or Tab. If you hit Enter, it will insert the text, as you describe above. But if you hit Tab, it will replace the text to the right of the text caret, and should give you the result you're after.

What is the keyboard shortcut to type fast in Visual Studio?

I am not sure what is the best way to word my question correctly in single line. But basically I have seen quite a few video tutorials now where the coder types really fast using some sort of shortcut to fill in the automatic text(prolly intellisense stuff) It looks very similar to Linux command line tab where you only type half of your text and when you hit tab it either fills in the gap or show you the remaining options.
Hope that makes sense.
Thanks
Pressing Ctrl+Space completes the current variable/class you are typing.
Typing things like ctor and then pressing the Tab key twice tells Visual Studio to insert a constructor for you. (Also works with for for a for loop, cw for a Console.WriteLine();, etc.)
For a full list, please refer to the official reference from MSDN.
I believe its Ctrl-Space, which is pretty common among most IDE's

Changing Ctrl + Tab behavior for moving between documents in Visual Studio

Is it possible to change how Ctrl + Tab and Shift + Ctrl + Tab work in Visual Studio? I have disabled the popup navigator window, because I only want to switch between items in the tab control. My problem is the inconsistency of what switching to the next and previous document do.
Every other program that uses a tab control for open document I have seen uses Ctrl + Tab to move from left to right and Shift + Ctrl + Tab to go right to left. Visual Studio breaks this with its jump to the last tab selected. You can never know what document you will end up on, and it is never the same way twice.
It is very counterintuitive. Is this a subtle way to encourage everyone to only ever have two document open at once?
Let's say I have a few files open. I am working in one, and I need to see what is in the next tab to the right. In every other single application on the face of the Earth, Ctrl + Tab will get me there. But in Visual Studio, I have no idea which of the other tabs it will take me to. If I only ever have two documents open, this works great. As soon as you go to three or more, all bets are off as to what tab Visual Studio has decided to send you to.
The problem with this is that I shouldn't have to think about the tool, it should fade into the background, and I should be thinking about the task. The current tab behavior keeps pulling me out of the task and makes me have to pay attention to the tool.
In Visual Studio 2015 (as well as previous versions of VS, but you must install Productivity Power Tools if you're using VS2013 or below), there are two new commands in Visual Studio:
Window.NextTab and
Window.PreviousTab
Just go remap them from Ctrl+Alt+PageUp/Ctrl+Alt+PageDown to Ctrl+Tab/Ctrl+Shift+Tab in:
Menu Tools -> Options -> Environment -> Keyboard
Note: In earlier versions such as Visual Studio 2010, Window.NextTab and Window.PreviousTab were named Window.NextDocumentWellTab and
Window.PreviousDocumentWellTab.
Visual Studio 2010 has, built in, a way to solve this.
By default, Ctrl+Tab and Ctrl+Shift+Tab are assigned to Window.[Previous/Next]..Document, but you can, through
Tools -> Options -> Environment -> Keyboard,
remove those key assignments and reassign them to Window.[Next/Previous]Tab to add the desired behavior.
it can be changed, at least in VS 2012 (I think it should work for 2010 too).
1) TOOLS > Options > Environment > Keyboard
(Yes TOOLS, its VS2012 !) Now three shortcuts to check.
2) Window.NextDocumentWindow - you can reach there quickly by typing on the search pane on top. Now this is your enemy. Remove it if you dont like it. Change it to something else (and dont forget the Assign button) if want to have your own, but do remember that shortcut whatever it is in the end. It will come handy later.
(I mean this is the shortcut that remembers your last tab)
3) Now look for Window.NextDocumentWindowNav - this is the same as above but shows a preview of opened tabs (you can navigate to other windows too quickly with this pop-up). I never found this helpful though. Do all that mentioned in step 2 (don't forget to remember).
4) Window.NextTab - your magic potion. This would let you cycle through tabs in the forward order. May be you want CTRL+TAB? Again step 2 and remember.
5) Now place cursor in the Press shortcut keys: textbox (doesn't matter what is selected currently, you're not going to Assign this time), and type first of the three (or two or one) shortcuts.
You'll see Shortcut currently used by: listed. Ensure that you have no duplicate entry for the shortcut. In the pic, there are no duplicate entries. In case you have (a rarity), say X, then go to X, and remove the shortcut. Repeat this step for other shortcuts as well.
6) Now repeat 1-5 for Previous shortcuts as well (preferably adding Shift).
7) Bonus: Select VS2005 mapping scheme (at the top of the same box), so now you get F2 for Rename members and not CTRL+R+R, and F7 for View Code and not CTRL+ALT+0.
I'm of the opinion VS has got it right by default. I find it extremely useful that VS remembers what I used last, and makes switching easier, much like what the OS itself does (on ALT+TAB). My browser does the same too by default (Opera), though I know Firefox behaves differently.
In Visual Studio 2012 or later (2013, 2015, 2017...):
Browse the menu Tools / Options / Environment / Keyboard.
Search for the command 'Window.NextTab', set the shortcut to Ctrl+Tab
Search for the command 'Window.PreviousTab', set the shortcut to Ctrl+Shift+Tab
Navigate to the blog post Visual Studio Tab Un-stupidifier Macro and make use of the macro. After you apply the macro to your installation of Visual Studio you can bind your favorite keyboard shortcuts to them. Also notice the registry fix in the comments for not displaying the macro balloon since they might get annoying after a while.
Ctl + Alt + PgUp or PgDn shortcuts worked to toggle next/prev tab out of the box for me...
After a couple of hours of searching I found a solution how to switch between open documents using CTRL+TAB which move from left to right and SHIFT+ CTRL+ TAB to go right to left.
In short you need to copy and paste this macro:
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports System.Diagnostics
Public Module TabCtrl
Public Sub TabForward()
Dim i As Integer
Dim activateNext As Boolean = False
For i = 1 To DTE.Windows.Count
If DTE.Windows().Item(i).Kind = "Document" Then
If activateNext Then
DTE.Windows().Item(i).Activate()
GoTo done
End If
If DTE.Windows().Item(i) Is DTE.ActiveWindow Then
activateNext = True
End If
End If
Next
' Was the last window... go back to the first
If activateNext Then
For i = 1 To DTE.Windows.Count
If DTE.Windows().Item(i).Kind = "Document" Then
DTE.Windows().Item(i).Activate()
GoTo done
End If
Next
End If
done:
End Sub
Public Sub TabBackward()
Dim i As Integer
Dim activateNext As Boolean = False
For i = DTE.Windows.Count To 1 Step -1
If DTE.Windows().Item(i).Kind = "Document" Then
If activateNext Then
DTE.Windows().Item(i).Activate()
GoTo done
End If
If DTE.Windows().Item(i) Is DTE.ActiveWindow Then
activateNext = True
End If
End If
Next
' Was the first window... go back to the last
If activateNext Then
For i = DTE.Windows.Count To 1 Step -1
If DTE.Windows().Item(i).Kind = "Document" Then
DTE.Windows().Item(i).Activate()
GoTo done
End If
Next
End If
done:
End Sub
End Module
The macro comes from: www.mrspeaker.net/2006/10/12/tab-un-stupidifier/
If you never add a macro to Visual Studio there is a very useful link how to do it.
The philosophy of the Visual Studio tab order is very counterintuitive since the order of the displayed tabs differs from the tab-switching logic, rendering the ordering of the tabs completely useless.
So until a better solution arises, change the window layout (in Environment->General) from tabbed-documents to multiple-documents; it will not change the behaviour, but it reduces the confusion caused by the tabs.
That way you will also find the DocumentWindowNav more useful!
I'm 100% in agreement with Jeff.
I had worked on Borland C++ Builder for several years and one of the features I miss most is the 'correct' document tabbing order with Ctrl-Tab. As Jeff said, "The current tab behavior keeps pulling me out of the task and makes me have to pay attention to the tool " is exactly how I feels about this, and I'm very much surprised by the fact that there aren't many people complaining about this.
I think Ctrl-F6 - NextDocumentWindowNav - navigates documents based on the document's last-activated time. This behavior is a lot like how MDI applications used to behave in old days.
With this taken this into account, I usually use Ctrl+F6 to switch between 2 documents (which is pretty handy in switching between .cpp and .h files when working on c++ project) even when there are more than 2 currently opened documents. For example, if you have 10 documents open (Tab1, Tab2, Tab3, ...., Tab10), I click on Tab1 and then Tab2. When I do Ctrl+F6 and release keys, I'll jump to Tab1. Pressing Ctrl+F6 again will take me back to Tab2.
I guess you want what VSS calls Next(Previous)DocumentWindow. By default, it's on Ctrl(-Shift)-F6 on my VSS 8. On Ctrl(-Shift)-Tab they have Next(Previous)DocumentWindowNav. You can change key assignments via Tools/Options/Keyboard.
In registry branch:
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0
add DWORD named "UseMRUDocOrdering" with value of 1.
It will order documents so most recently used are placed on the left. It's not perfect but better than the default misbehaviour.
Updated to VS 2017+, where, according to #J-Bob's comment under #thepaulpage's answer, (emphasis added):
Looks like the commands have changed again. It's now 2017 and the keyboard shortcuts are called Open Next Editor and Open Previous Editor. You don't need any extensions for this.
You can find the options under Settings, which can be accessed via the gear symbol in the lower left, or by the [Ctrl]+, command.
I feel the top answer at the moment is outdated. In Visual Studio 2021 (v1.56), you do not need to install any extensions or mess around with any configuration files. You simply need to do the following steps:
Click the gear icon in the bottom-left.
Select 'Keyboard Shortcuts'.
Search for 'workbench.action.previousEditor' and 'workbench.action.nextEditor' and edit their keybindings by clicking the pencil icon on the left side of the row.
If you do change to 'Ctrl+tab' or any other shortcut that is already in use by another command, it will let you know and give you the option to change those. I personally changed them to 'Ctrl+PgUp' and 'Ctrl+PgDn' so it was just a straight swap.
I don't use Visual Studio (yes, really, I don't use it), but AutoHotkey can remap any hotkey globally or in a particular application:
#IfWinActive Microsoft Excel (application specific remapping)
; Printing area in Excel (# Ctrl+Alt+A)
^!a::
Send !ade
return
#IfWinActive
$f4::
; Closes the active window (make double tapping F4 works like ALT+F4)
if f4_cnt > 0
{
f4_cnt += 1
return
}
f4_cnt = 1
SetTimer, f4_Handler, 250
return
f4_Handler:
SetTimer, f4_Handler, off
if (f4_cnt >= 2) ; Pressed more than two times
{
SendInput !{f4}
} else {
; Resend f4 to the application
Send {f4}
}
f4_cnt = 0
return
These are two remappings of my main AutoHotKey script. I think it's an excellent tool for this type of tasks.

Resources