How to replicate SublimeText ctrl+D in Visual Studio - visual-studio

I am used to work with Sublime text and trying to switch for Visual Studio for bigger projects, one of the feature of sublime that I absolutely love is its multiple select feature. You can hit ctrl + d multiple times to select next instance of the same word and then rewrite them all at once. Is there anything like this in Visual studio? I tryed to find it, but with no success.
Btw I am using Visual Studio 2015.

Visual studio 2017-19
The default shortcut is Alt+Shift+.
But if you want to add Ctrl+D
Go to the menu Tools > Options then select the Keyboard tab on the left
At the top you'll find an option to add extra keybindings, select Visual Studio Code. Save and That's it!
This works because Visual Studio Code has Ctrl+D, and other shortcuts similar to SublimeText
Alternatively you can manually add shortcuts
In the image, you can find any command to customize in the middle section.
The particular command you are interested is the one selected Edit.InsertNextMatchingCaret

Ctr R, R, this is used to replace the name of the varibals, depronto can serve it.
and you are encouraged here are all the shortcuts of vs2015 http://visualstudioshortcuts.com/2015/

Goto Tools / Options / Keyboard
Search for duplicate
Choose Edit.Duplicate
Remove the assignement for the current shortcut
Assign the shortcut you want

Ctrl + Shift + L seems to work.

Use Alt +leftClick and ctrl+F2 . For more reference you can go Official Website [link]https://code.visualstudio.com/docs/getstarted/keybindings#_keyboard-shortcuts-reference

I decided to use this Visual Studio Extension:
https://marketplace.visualstudio.com/items?itemName=JustinClareburtMSFT.SublimeVS

Related

Visual Studio: Shortcut to close window not working

I changed the shortcut to close a window to Ctrl+W and to close all windows to Ctrl+Shift+W. Close all windows works fine, but Ctrl+W selects the word currently under the cursor but does not close the window.
When I right-click a tab it say Ctrl+W is the shortcut to close it (And also Ctrl+S to save and Ctrl+Shift+W to close all). Why is only the close window shortcut not working?
In Visual Studio (VS 2015 in my case but it's similar down to VS 2010 at least) keyboard shortcuts may have a different meaning depending on the context in which they are executed.
Click Tools / Options / Environment / Keyboard to look up or define shortcuts (you already did that probably). What I called "context" is selected in the combobox labelled "Use new shortcut in:". Most likely you defined the shortcut in "Global" but you want it to work in "Text Editor". In the latter Ctrl+W selects the current word.
Redefine Ctrl+W for "Text Editor" and you should be fine.
I am using Visual Studio 2017 & Visual Studio 2019 and tried the answer from #TobiMcNamobi but it didn't work for me. After few such tries I got it work with below steps.
You should add it as Global shourtcut otherwise it will not work for Designer views.
Add CTRL+W as a Global shortcut for Window.CloseDocumentWindow
Remove the CTRL+W shortcut for Edit.SelectCurrentWord
In Visual Studio 2019 it is Ctrl-F4 by default to CloseDocumentWindow. The action is Window.CloseDocumentWindow. I know this is old but the accepted answer has you change the short-cut key instead. I would rather use the default option.
Tools -> Options -> Environment -> Keyboard
If you're ever unsure go to the path above and you will see the image above then you can click inside the box "Press shortcut key" at the bottom of the form and type the short cut key you're interested in and it will tell you if it is used and what it is currently used for.
You can also reference the docs
https://learn.microsoft.com/en-us/visualstudio/ide/default-keyboard-shortcuts-in-visual-studio?view=vs-2019
2021: For Visual Studio 2019:
See: https://gist.github.com/jpoehls/2030795#gistcomment-2335647
In my case, I had to existing assignments that I had to remove. Thereafter, I could use the hotkey.
In my case, the tabs were not closing because I am using Vim extension. I had to add the following lines to Vim settings:
"vim.handleKeys": {
"<C-w>": false
}
Just press Ctrl + , or Command + , for Mac users, search for Vim and go into Edit in settings.json as the following picture shows:
Screenshot
For Visual Studio 2022, make sure you also remove Ctrl+W from selectCurrentWord command.
In my VS Pro 2019, on Tools / Options / Environment / Keyboard, the first line offers using a premade keyboard mapping scheme, with a drop-down option for VSCode keyborad mapping theme.
I picked it and it seems to have adopted the keyboard shortcuts I was used to from working on VSCode, Ctrl+W included.
For those using linux with VSCode v1.56.2,
File --> Preferences --> Keyboard Shortcuts.
Search for View:Close Editor and as mentioned above, remove any keybinding that has the keybinding you want.

Keyboard shortcut for the "Update options..." variable drop down in Visual Studio 2013

In VS 2012 Ctrl + . would enter the drop down that is highlighted at the bottom right of a variable name when the name itself is changed. You could then update all references to the variable with the keyboard only. I cannot get this to work in VS 2013, and am missing it greatly! Does anyone have any idea how to get this working in 2013??
Thank you for your help!
Take a look at this. It has all the keyboard shortcuts available for VS2013. Including Ctrl + Dot
If it still does not work, have a look at the configuration here (This is for VS2012, but I would imagine its' is the same for 2013)
If you go Tools > Options > Environment > Keyboard. The command you're looking for is View.ShowSmartTag.
You can then assign the shortcut you want (ctrl + .) to this command.

What's the equivalent for eclipse's ALT+UP/DOWN (move line) in Visual Studio?

In Eclipse, selecting a line and pressing Alt + ↑/↓ will move the line up and down, a quick way to avoid copy&paste.
Is there an equivalent in Visual Studio?
In Visual Studio 2013 and later, this functionality is built in. ALT + UP/DOWN will move a line up or down.
If you need this functionality in VS2012 (works with VS2010 too), take a look at the MoveLine Visual Studio Extension or the Productivity Power Tools suite.
ReSharper's Ctrl + Shift + Alt + ↑/↓/←/→ is even more powerful - when on the beginning of the line, it will move the entire line, but can also be used to move entire methods, change the order of parameters, etc.
For me in Visual Studio 2019 it comes default closed.
For open it:
Tools -> Options -> Keyboard then select Edit.MoveSelectedLinesUp, click "Press shortcut keys" input and press Alt + Up (or whatever you want for it). And the other one is Edit.MoveSelectedLinesDown, click "Press shortcut keys" input and press Alt + Down (or whatever you want for it).
This is now working out of the box with Visual Studio 2013, same way as in Eclipse.
For Visual Studio 2013:
Tools -> Options -> Keyboard then select Edit.MoveSelectedLinesDown, click "Press shortcut keys" input and press Alt + Down. You also have to select the scope of the shortcut to be within "Text Editor".
In Visual Studio 2013 and later, you can move lines up and down using Alt + ↑ / Alt + ↓. Unfortunately this will not adjust the indentation if you move between blocks, as of today only ReSharper (and all other IDE's by Jetbrains including Rider) can help you with that.
To move entire blocks of code around you can move the cursor to its head and press Ctrl + m twice fast to collapse it, and then use the command above to move it around.
Here is a neat reference to all default keyboard shortcuts in different versions of Visual Studio.
With the VSCommands extension, you have exactly that keyboard shortcut. And, by the way, a Stack OVerflow notification toolbar :)

Is there a way to quickly find files in Visual Studio 2010?

Does Visual Studio 2010 have a built-in way to quickly find/open files, similar to the Ctrl+Shift+O function in Eclipse?
Or does ReSharper offer this functionality?
Ctrl+,
I'm surprised no one gave the right answer:
Navigate To can show you a list of open files and lots more.
http://weblogs.asp.net/scottgu/archive/2009/10/21/searching-and-navigating-code-in-vs-2010-vs-2010-and-net-4-0-series.aspx
CTRL+COMMA is your friend.
Ctrl + Alt + A opens the command window, type "open" then start typing file names and it will dynamically autocomplete by available solution file name.
I use Ctrl + / to jump to the command bar (same as the search box, but with a > prefixed in the text). I then type "of" (for "open file") and start typing the name of the file to open. Possibly matches are automatically displayed by VS.
I also found that when using ReSharper, the familiar Eclipse shortcut for Open Type (Ctrl + Shift + T) is mapped to ReSharper's GotoFile command.
There is also another way to find files in the Visual Studio 2010 might be useful for someone.
In the command box in visual studio toolbar type ">of " and start typing the file name it will prompt list. Note: This will only find the class not the pages try it for yourself.
this addin will very usefule to quickly open files from visual studio by pressong CTRL + K + O
http://visualstudiogallery.msdn.microsoft.com/en-us/3eb2f230-2728-4d5f-b448-4c0b64154da7
In VS2017 or later versions, we have command called "Edit.GoToAll".
SO can configure it from VS tools.
see below snap.
I have configured my keys for file search as CTRL + SHIFT + T
CTRL+SHIFT+F will bring open a find in files search dialog box. The result will be listed, usually, on the lower section of VS in a Find Files result box. Double clicking a result will open it
DPack has a dialog for finding files in the current solution (search all, or only open files), and it also has a dialog to search the current file for methods,properties, etc. Very nice! Note that the current version only supports VS 2012 or newer, but they have binaries there for older versions of VisualStudio as well:
http://www.usysware.com/dpack/
You could also try Sonic File Finder, which does something similar to CTRL+COMMA:
http://www.jens-schaller.de/sonic-tools/sonicfilefinder/overview/overview.htm
In Eclipse, Ctrl+Shift+O = "Organize Imports"... which I am not sure what this is. But it is not the Ctrl+Shift+F = Find in Files that is in Visual Studio.
VSFileNav - An extension that I created that allow rapid file searching. It's basically got all the ReSharper functionality that was disabled in the express version of VS2010 (I used to really like this).
It's also free :)
For file name search, I use the Visual Studio Productivity Power Tools.
It adds a tab to Solution Explorer called "Solution Navigator". It shows all the solution files in a tree and has a search bar at the top.
To search for text in all your solution files, use Entrian's Source Search:
https://stackoverflow.com/a/9994522/24267
Visual Assist comes with something like this. You will have to pay for the plugin (and I don't think you can use plugins in the express versions).
(If you're doing C++ and you don't plan to buy Visual Assist, be sure to never install the trial. It's that addictive.)
I usually use Ctrl+Q or Everything tool via a hotkey.
For fuzzy search of files (and more) I needed to use cmdp
Unfortunately, VS doesn't offer this search-as-you-type functionality (and lots more).
Type >open filename in the command box in the Visual studio can also open the file
NavigateToAll extends the built-in Navigate To by enabling you to open any file on the disk (not just the ones in the solution).
CTRL + P, the right solution for me....
CTRL + , -> SETTINGS

Key shortcut (hotkey) in Visual Studio to open a file inside your solution?

Is there a key shortcut in Visual Studio to find & open a file inside your solution without using Resharper or any other tools?
The accepted solution doesn't work on the newer versions.
For Visual Studio 2022, and 2019, 2017 do the following:
Update 1:
Now, pressing Ctrl + Shift + T and typing the file name works!
Update 2:
Since Visual Studio 2019 now it's possible to do a similar search via Ctrl + Q.
But it works slightly sloppy since it shows VS-related stuff as well.
Original answer:
Press these keys to open the "Go to" popup:
Ctrl +
,
Type there:
f Space Filename
Press Enter
Notes:
We are writing f to make VS search only on files. We can
also, use other letters. For more info type ? in the "Go to" popup.
For more keys and for Visual Studio 2012 to 2015 take a look at this
answer.
This answer is outdated; see here for latest information.
Not a single keystroke, but yes: `Ctrl+D > o f filename` (so that's five keystrokes before you start typing the filename). It then autocompletes the filename for you.
You need the Find box in the toolbar for this to work.
(If you change your mind about addins, SonicFileFinder is for this very purpose, and free.)
You can also use Ctrl + /, which puts the > in place for you automatically.
Similar to Just Shadow's answer I discover that, on Visual Studio 2017, you can do the following:
Press Ctrl + 1, then f
Or you could go to Tools -> Options -> Keyboard
and change the shortcut of Edit.GoToFile for whatever you like.
I replaced mine with: Ctrl + O

Resources