Visual Studio : How can I remap the Ctrl+E key? - visual-studio

I am using Visual Studio 2013, and I would like Ctrl+E to map to Edit.LineEnd. Basically, the same thing that happens when you hit end.
I can remap it under options/environment/keyboard, but the problem is visual studio still treats Ctrl+E as a chord. Instead of going to the end of the line when I hit Ctrl+E I see a message below :
(Ctrl+E) was pressed. Waiting for second key of chord.
This does not happen when I remap Ctrl+A, Ctrl+N, Ctrl+P, Ctrl+F, or Ctrl+B.

This looks like a side effect of how Visual Studio layers command routing and key bindings...
If you look at the default bindings (my settings were based on the C# profile), you can see there are a ton of other bindings that start with Ctrl+E:
Important observations:
Each command has its context specified in parenthesis (Global, Text Editor, Workflow Designer)
There is already a multi-key (chord?) binding in the Text Editor
The Workflow Designer bindings don't matter/conflict because they're in a completely separate context
If you set your binding in the Global scope, it falls last on the priority (i.e. any specific context overrides a more generic one). Since you're in the text editor, it's trying to match the chord that exists in that context.
If you were to bind your new shortcut in the Text Editor (that's the dropdown labeled Use new shortcut in:, which defaults to Global), it would actually remove the keybinding for Edit.ToggleWordWrap. That's because you can't have a keybinding overlap with a chord, so VS assumes you really want the one you're trying to add and nukes the conflicts.
Alternatively, if you want to keep both, you could remap Edit.ToggleWordWrap to a different binding first.

Related

How to jump words in text editor

I used to be able to hold down the Ctrl key and press arrows to jump over words in a text for navigation or selection of text. I even had it configured that it would respect camelhumps. However after a new installation of Visual Studio these settings have been lost. I've also installed CodeRush, but haven't found anything like these features in there.
Edit versions added:
CodeRush v20.1.3, trial
Visual Studio 2019 16.4.6
I've found this function on the ALT key. In order to make it work on the CTRL key, that key had to be the only key with the function. If I made it an alternative key, the text editor would just lose focus when pressing CTRL+LEFT.

Is there a shortcut to move the cursor as shown in the following figure?

I am using a notebook without a mouse.
After typing prop and pressing tab, Visual Studio will automatically give me a property template. Pressing tab will move the cursor between type and propertyname placeholders.
I want to move the cursor to a new line after completing the property template.
Is there a shortcut to do so?
Press the Enter key twice.
I tried to post this answer 3 times before I left the comment. It wouldn't let me, too short. That's why I'm typing this otherwise useless verbiage.
It's not specific to snippets, but you can press Ctrl+Shift+Enter to start a new line below where the cursor currently is.
To insert a new line above where the cursor currently is, use Ctrl+Enter.
Both of these work anywhere in the editor. Both of these are handy because they work no matter where you are horizontally on your current line.
Update: Productivity PowerTools for VS2010 (Woot! 2012 too) provides the keyboard shortcut Tools.AddEndTokenAtEnd. (Thanks Ben.)
For some reason, magically, my VS2010 does this with Shift-Enter (which I prefer from my experience with TextMate.) Looking at my keyboard bindings (Tools > Customize > Keyboard) I see that this shortcut is assigned to the command Tools.AddEndTokenAtTheEnd. So if that command appears in your list of commands, assigning a keyboard shortcut to it should work. I have Productivity Power Tools, PowerCommands for Visual Studio 2010, and ReSharper installed. But I can't find any setting from the first two that would be responsible, and, in my experience, all of ReSharper's commands contain its name, so I don't think it added the command. Ooo, and I just discovered that the reason it is named that is because the command also ensures there's a semicolon at the end of the initial line before moving the cursor down; just like the useful keyboard shortcut in Textmate.
I'm interested, but baffled by the 2x-Enter solution. When I press enter twice I get two line breaks followed by whatever code was after the cursor on the first line. Can anyone explain how that shortcut/key-combination works? Is it time-sensitive so that the two enters must be pressed in rapid succession? What if the user wants to quickly insert some lines above some code and hits Return multiple times!?

Refector-Rename ASP.Net Controls

Is there any way to Rename ASP.Net Controls without searching the complete Markup or Codebehind.
In Visual Studio there is Refactor Rename but this only works in Codebehind I still have to search the Markup code.
I'm using VS 2008.
Yes. I've found that the easiest way to do this is from the code behind.
There exists a shortcut called Rename Refactoring that is bound to the keyboard combination (Ctrl+R, Ctrl+R). The combination is listed as "Refactor.Rename" in the keyboard settings, if you want to change the shortcut (or if it's not bound, for some reason, you can set it yourself.)
To rename your ASP.NET control, navigate in the aspx.vb file to a reference of the control. Put your mouse cursor on the variable name. Press the keyboard shortcut. Now, you can either start typing (will erase the previous name and start typing a new name), or click somewhere or use the arrow keys to navigate to a specific position in the variable, after which you can add/remove/change the name as you please.
Clicking elsewhere will not apply the changes. To apply the operation, either click "Apply" in the dialog at the top-right that appeared, or press Enter.
The ASP control will be renamed in the VB code, and in the aspx code!
Note that there are certain file types where Refactor.Rename is "not available", such as .ashx or Visual C++ files.

visual studio shell F# keyboard shortcuts

I've started using F# with the visual studio shell and I like the capability to be able to send lines to fsi by highlighting them, but the alt+Enter shortcut is really awkward and I would be much happier with this being on shift+Enter. (mainly since shift+ up/down arrow is select lines already)
Does anyone know how to change this? Thanks.
You can alter the keyboard mappings within Visual Studio. If you go to Tools -> Options -> Environment -> Keyboard, you'll see a window like the image below.
In order to check existing bindings, place the cursor in the "Press shortcut keys:" box and hit "Shft+Enter". You'll then see any potential conflicts in the drop-down box as shown.
In the example below, I'm searching through Global, which means shortcuts for anything in the application. You can switch it to be just the console or whatever you like.
Once you're happy with the shortcut you want to use, you need to select the command from the window containing all of the Action.* lines and then press Assign.
So I don't mean to be trite, but have you tried mapping the key?
So for F# Interactive I see Alt+Enter mapped to:
ClassViewContextMenus.ClassViewMultiselectProjectreferencesItems.Properties
Have your tried mapping Shift+Enter (or whatever) to that command?
Tools->Options->Environment->Keyboard
You should be able to get it all working from there.

navigate to calling code Visual Studio

I want to know that we can use F12 to jump to the function that is called from this code , if i have to return to the code again how I can do this.
I believe that the command you're looking for is "Navigate Backward", available from the View menu (or CTRL+-). It has a companion command, once invoked, called "Navigate Forward", also on View menu (CTRL+SHIFT+-).
You can use these to move back and forth through a chain of Calling/Callee functions. Obviously, if you're not using the usual Visual Studio shortcut mappings, then the key combinations above may be different (or you may have to assign keys yourself).

Resources