Move caret line start/end in Visual Studio 2019? - visual-studio

I want to remap moving the caret to the beginning/end of a line of text, as what Home and End are doing right now. However, I'm unable to find which commands actually control this.
Any suggestions?

When you press Home in the Press shortcut keys field of the keyboard options dialog, it shows the corresponding command Edit.LineStart:
Similarly for End the command is Edit.LineEnd.

Related

Rearrange Code shortcut in Resharper doesn't work in VS2015

When I try to use the shortcut for moving lines up/down (Ctrl+Alt+Shift+↑/↓), it highlights the code and shows the tooltip message "Use Up/Down to move text line" but nothing happens. If however I try the same command via the menu bar (Resharper > Edit > Rearrange Code > Move Up) it moves the selected lines as expected.
I used to use this feature all the time so I find this bug very annoying. Apparantly, others also experience this (see comments for Resharper move line up down not working) but I haven't been able to find a solution for it. Resetting keyboard layouts and reapplying VS keyboard schemes doesn't work.
Has anyone been able to resolve this issue?
[EDIT]
Reason of this is issue (when you are logging to machine with VS and Resharper via Remote Desktop) is that Ctrl-Alt-Left Arrow/Ctrl-Alt-Right Arrow combinations are not sent to your virtual machine
There are two workarounds:
My first soultion (change combination see below)
You can use AutoHotKey script as stated in thread:
https://superuser.com/questions/327866/remote-desktop-sending-ctrl-alt-left-arrow-ctrl-alt-right-arrow-to-the-remote-p
[/EDIT]
Reason is
duplication of the same hotkeys which could be found in 'Shortcut currently used by:' combobox
Fix is
I described process for _MoveRight shortcut - for other shortcuts it works the same
STEP 1 Check for conflicting changes
seeImage
go to Tool --> Options --> Keyboard
in field 'Show commands containing' find your command (moveright in example)
click in field 'Press shortcut keys' press ALT + RIGHT ARROW
in field Shortcut currently used by you will find conflicting shortcut -
Edit.CompleteWord...
STEP 2 Now we need to delete this shortcut
in field 'Show commands containing' write Edit.CompleteWord
you should see ALT + RIGHT ARROW shortcut in field 'Shortcuts for selected command
click Remove button
STEP 3 Now we need to add our shortcut to _MoveRight function
in field 'Show commands containing' find your command (moveright in example)
click in field 'Press shortcut keys' press ALT + RIGHT ARROW
click Assign

Is there a way to select block of code in Visual studio just by double click like in Eclipse?

In Eclipse you can double click next to an open brace and that selects the block of code, however in Visual Studio you need to press the CTRL+SHIF+]! How can i edit this shortcut so that simply a double click does the same thing? (holding too many keys is just too much)
To change how the text editor interacts with the mouse, you'll have to develop a Visual Studio extension. Or, you can just change the keyboard shortcut to perform this action to whatever you like. You can do this from Tools/Options/Environment/Keyboard and select the command Edit.GotoBraceExtend. Enter the new shortcut in Press shortcut keys by pressing them then click Assign and OK.
Note that if the shortcut you have selected was assigned to some other command, the assignment will change.
Try ctl+m+m anywhere in the code block. This will collapse the code accordingly and then you can copy

Visual Studio: how to make pressing tab key indent the whole line

Is there a way to configure a keyboard shortcut in Visual Studio such that tab (or some other key combo) indent the whole line (rather than insert a tab character/spaces at the cursor)?
Trying to determine whether Visual Studio is the dream editor
EDIT
I'm an experienced VS user, I know about the standard behavior, just curious whether it can be configured with the interesting tab behavior described in the link.
Increase indent:
Select / highlight line(s) or press Home
Press tab
Decrease indent:
Select / highlight line(s) or press Home
Press shift + tab
If you want to add a shortcut to do the same from anywhere in the line without selecting it then you can add a shortcut in Options -> Environment -> Keyboard. There'll be a list of commands including Edit.IncreaseLineIndent and Edit.DecreaseLineIndent. I couldn't find a good key combination for a shortcut though which wasn't already being used for something else. You can't use just tab by itself.

Waiting for second key of chord

I have assigned the keyboard shortcut Ctrl+E to a command. But when I click Ctrl+E, the status bar says Ctrl+E was pressed. Waiting for the second key of the chord...".
If I hit the Esc key, I get "The key combination (Ctrl+E, Esc) is not a command."
How do I activate the command that has been assigned to Ctrl+E?
I know that this is the same as the question How do you stop Visual Studio from waiting for the second part of a shortcut-combination? . But the answer given there (hit Esc) does not work for me.
The selected answer is wrong in stating you cannot use Ctrl+E by itself (at least for Visual Studio 2013).
For those who come from a Mac or other OS background where Ctrl+E takes you to the end of the current line (the End key shortcut by default in VS), this is a really frustrating limitation when switching environments.
I found that in Visual Studio 2013 at least, you can remove all the shortcuts that use the Ctrl+E chord (none of which I will ever use) and set the Edit.LineEnd command to Ctrl+E. It just takes a few minutes tracking down the chords to remove (most of them are under the workspace designer).
To see which commands are using your keyboard shortcut at the moment, enter it
in the "Press shortcut keys:" edit box. Make sure you don't accidentally click "Assign".
In the dropdown box "Shortcut currently used by:" you can browse
through and manually remove all commands that
currently occupy your desired shortcut combination.
Key chords are a keyboard shortcut feature of Visual Studio. They consist of a sequence of key presses like (Ctrl+K, Ctrl+C) for comment code or (Ctrl+K, Ctrl+U) for uncomment code.
They are activated by the user pressing one Ctrl+key combination, then another Ctrl+key combo. For example Ctrl+K, Ctrl+C on my install of Visual Studio is used for commenting selected text.
In your case, Ctrl+E is a common chord starter and is used by many chords. For example Ctrl+E, Ctrl+W = Toggle Word Wrap and Ctrl+E, Ctrl+X = Workspace Designer.ExpandAll.
Depending on which developer setting you've chosen for the IDE, Visual Studio might have Ctrl+E mapped to other chords. In that situation, you cannot use Ctrl+E by itself for a keyboard shortcut
If this is the case, you can create your own chord, Ctrl+E, Ctrl+D is not in use on my install of Visual Studio 2012.
Edit:
Also if you remove all key chords that start with (Ctrl+E) then it can work as a non-chord shortcut.
And your question is not the same as the other question. In that question, the OP has started the chord process (Ctrl+E) and wants to cancel Visual Studio from waiting for the 2nd chord key.
I came to this question because I had the same problem as the OP, but in the Integrated Terminal of Visual Studio Code (not Visual Studio).
My problem:
I couldn't stop the node server by doing Ctrl+C, because my VS Code was waiting for the "second key of chord"...
I fixed it in the user settings, by unchecking the Allow Chords checkbox.
I answered the more suitable question for me here.
I have had the same issue with my "<" [backquote] key and wasn't able to find the right keybinding in the normal settings. Allow chords wouldn't do anything either.
This is for anyone, who isn't able to reasign the key in the default keybindings:
Find the User settings in your terminal.
Windows %APPDATA%\Code\User\
macOS $HOME/Library/Application Support/Code/User/
Linux $HOME/.config/Code/User/
Open the keybindings.json file
look for all chords that you would like gone.
(Obviously) remove/alter them
I hope I could help some of you!
You can disable it only for the integrated VSCode terminal by adding the following to your setttings.json file:
{
...
// Disable chords for terminal usage
"terminal.integrated.allowChords": false
...
}
Go to Tools -> Options.
A window will open up, In that Environment -> Keyboard -> Keyboard
And Just Press the Reset button on the right.
Screenshot
Do
ctrl+ E
then
ctrl + V
More info here:

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!?

Resources