Visual Studio Code highlighting and clicking copy pastes - visual-studio-code

When I highlight some text with my mouse and then click off of the highlighted text, sometimes it copy pastes that text right after what was highlighted. I don't want it to copy paste on click, I just want it to unhighlight. I looked through the settings and configurations of my VS code, and couldn't find a way to turn it off. Any ideas?

The behavior you mention sounds a lot like the copy, drag and drop functionality that vscode offers and I occasionally accidentally trigger. It can be disabled by setting to false:
// Controls if the editor should allow to move selections via drag and drop.
"editor.dragAndDrop": false,

Related

Access mouse over hover in VSCode

Is there a way to access the mouse over popup in VSCode via Keyboard and navigate in it?
I often use the mouse over to get the namespace of function or variable ...
So I want to place the cursor on "bar", popup the hover (Show Hover Ctrl+k Ctrl+i), focus it, mark some text (eg. namespace::functioname), copy and close the hover.
namespace foo{
void bar();
}
First problem, the hover doesn't get the focus and I don't know how to focus it. But there is another feature "Show defintion preview hover", which actually gets focused. So far so good. But I still cannot mark or copy text inside the hover via keyboard.
Show hover (not focused):
Show definition preview hover (focused):
But I still cannot mark or copy text inside the hover via keyboard.
That should change with VSCode 1.68 (May 2022):
Lock hovers to more easily mouse over them
Some custom hovers cannot be moused over and others are tricky to mouse over without hiding it because of other things in the way (eg. like a scroll bar).
Holding alt while a hover is active will now "lock" it, giving it a wider border and preventing moving the mouse outside of the hover widget or whatever triggered it from hiding it.
This is primarily an accessibility feature to make hovers play nice with screen magnifiers but it is also useful for copying text from certain hovers.
Note that this feature only applies outside of the editor because editor hovers can always be moused over unless specified otherwise via a setting.
This will be helpful for other views (debug, terminal, ...) where variables with their popup can appear as well.
In the editor, see microsoft/vscode issue 63296
ctrl+K ctrl+I to show the hover and focus it
ctrl+A to select all the hover content
ctrl+C to copy to clipboard
It does indeed work for me (on windows) for the first two steps, however ctrl+C does not copy the text selected with ctrl+A.
It seems like there are two different selections possible in the hover:
ctrl+Aselects everything with a dark blue.
When selecting some text in the hover with the mouse (i.e. press the left mouse button while near/over a char, move mouse, release left mouse button) the selected text is shown in a lighter and brighter blue.
The two selections can coexist.
ctrl+C always copies the text selected with the mouse, or nothing if there's no such selection, no matter whether a ctrl+A selection also has been done.
If there's only a ctrl+A selection, ctrl+C doesn't copy anything.
The two selections can be selected in any order. The order doesn't change the behavior.
Think I found out what you were after.
The shortcut is: Ctrl+K Ctrl+I
See: Trigger advanced hover information with keyboard
please try control + mouse click
it may be help you

How do I stop Visual Studio Code (VSCode) from linting new, unsaved files?

In Visual Studio Code (VSCode), I often want to temporarily store some text while coding. A quick way to do this is to hit Ctrl + N (to open a new file in a new tab) and then Ctrl + V (to paste the text). I can then go back to the new tab later on and retrieve the text. This is safer than using the clipboard, because I don't want to accidentally blow it away by copying something else.
However, the ESLint extension for VSCode will automatically detect that I have pasted some JavaScript code into a new file and will immediately start linting it, even though it is a brand new & unsaved file. This clutters up the "Problems" pane with spurious errors.
How do I prevent this from happening?
The solution is to click on the language icon in the bottom right hand corner, and switch it to Plain Text (plaintext).
This will obviously disable the linter, because it won't be a JavaScript/TypeScript file anymore.
It's also probably possible to make a VSCode hotkey that will do this in one keystroke, but I don't really do this pattern often enough to justify making a custom hotkey for it.
Search preferences for "Format on paste" or in settings.json enter:
"editor.formatOnPaste": true

VSCode: Disable mouse+ctrl interaction

I often double-click to select followed by ctrl+c to copy. I am finding in vscode that ctrl press with the mouse over a word can perform an action. In some cases it selects the whole line, and in others it jumps to the definition of what is underneath. Is there a way to turn this off?
Note that if you move the mouse cursor off the word then it appears the action is not performed.
You could click on Visual Studio code->Preferences->KeyBoard Shortcuts. Keyboard Shortcuts page opens up. You could change any of the keyboard short cuts, by click on edit icon on the left as shown below
You can change the behavior of these features or disable them altogether by going to Tools > Options > Text Editor.
https://devblogs.microsoft.com/cppblog/productivity-structure-visualizer-ctrl-click-to-go-to-definition/

Disable multi cursor functionality

I do not like the Visual Studio multi cursor options, and I never use them.
Inevitably, I phantom-pressing some key combination that brings up a multi cursor option, then I write some code, and then the code is destroyed afterward. Please tell me how to completely disable all such functionality in Visual Studio Code. I am running on Ubuntu, but also interested in how to accomplish this on Windows (if there is any difference).
I should mention, that this happens literally once every 5 minutes to me on Ubuntu, but in Windows it happens much less frequently (like once an hour).
Un-check Selection->Column Selection Mode
You can remove the keyboard shortcut(s) that trigger this functionality.
Click on the gear on the bottom-left corner of the window and choose "Keyboard Shortcuts" from the menu. Type "Add Cursor" into the "Search" box and it shows only the commands that contain "Add Cursor" in their name.
Right-click on each command that add a cursor and has a keyboard shortcut associated and select "Remove Keybinding".
Also search for "Multi-Cursor". It could return the command "Toggle Multi-Cursor Modifier" that is associated to a combination of modifier keys (one or more of Ctrl, Alt, Shift). If such a combination of keys is pressed when you click in the editor window it adds a new text cursor at the click position. You should also removed these key bindings.
Set this settings in editor settings :
"editor.columnSelection": false,
In Android Studio :
Un-check Selection->Column Selection Mode

How can I change visual studio code mouse click events?

For exemple I want to set the editor mouse click. When I click a file
should be opened in a separate window, not when I double click on the
file.
Anything that can be changed, can be changed with settings:
press F1:
You will see a list of settings you can search through:
Otherwise there might be a plugin for that, or you have to make a plugin yourself.