How to disable the light bulb in Visual Studio Code - visual-studio-code

I love Visual Studio Code but I hate the little lightbulb. It seems to clash with the dropdown when you Ctrl+. on word.
How do you disable the lightbulb in Visual Studio Code?
Just to clarify - I always use the Ctrl+.. But on the first time when I try to navigate down the drop down menu the menu disappears and the lightbulb re-appears. I then have to Ctrl+. again to go down the drop down list and get the selection I want. I just want to disable the lightbulb itself, not other functionality such as the quick fixes.

There's a new option that you can use to disable that. Go to your settings file and add:
"editor.lightbulb.enabled": false

Go to: > File >Settings
Enter "bulb"
Click on the checkmark to remove it.

Seems to me that the arrangement of the lightbulb has changed since the answers above. In my version of VS Code, the easiest way to disable or enable the lightbulb is to just type lightbulb on the Setting search bar.
Go to Setting
Type "lightbulb" or "bulb" on the Setting's search bar,
Check or uncheck the "Enable the code action lightbulb in the
editor"
If you don't want to use the search bar: go to
File > Preferences > Settings > Text editor
Then scroll down the list to find "Enable the code action lightbulb in the editor". Check or uncheck as you prefer.

I'm not sure what you mean. You want to disable the visual element of the lightbulb? Or you want to eliminate "quickFix" altogether?
There is this keybinding which triggers the same action as the lightbulb:
{
"key": "ctrl+.",
"command": "editor.action.quickFix",
"when": "editorHasCodeActionsProvider && editorTextFocus && !editorReadonly"
}
If you are wanting to disable the keyboard shortcut you could do that by adding this line to keybindings.json
"key": "ctrl+.", "command": ""
If you want something ELSE mapped to "ctrl+.", then you can put that command in the command above.
If you're wanting to disable the lightbulb itself from appearing, I don't think that is possible.

Related

How to use keyboard to focus on git commit message input in VSCode?

Is there any way to focus to this input by keyboard rather than mouse click in Visual Studio Code?
While certainly not ideal, I've found the following will focus the Source Control Message input field:
ctrl shift G
then, ESC
then, Tab
Now when you repeat ctrl shift G it seems to focus the input directly.
As a workaround, we can use the extension multi.
Define shortcut like:
{
"key": "escape",
"command": "extension.multiCommand.execute",
"args": {
"sequence": [
"list.focusFirst",
"list.select",
]
},
"when": "listFocus && workbench.scm.active",
},
If you are in any section in the left menu other than Source Control (e.g. Explorer or Extensions, then use Ctrl+Shift+G then press G again
If you are already in the Source Control section of the left menu, then use Tab or Shift+Tab to move focus forward or backward (respectively)
You can use TAB/SHIFT+TAB key to move focus in left SOURCE CONTROL panel.
For some color theme you can easily notice where the focus is.
Most of the time the focus is located on the file names in Changes pane(?). In that case press SHIFT+TAB key to move focus to Message field.
First, if needed, focus Source Control with Ctrl+Shift+G.
Press Home to focus the message box and Enter or Tab or Space to start typing in it.
Thanks to yellowtailfan for bringing this up on GitHub. They specifically said "if one of the changed files has focus", but I don't think that's crucial for Home Enter to work.
Overall, you can navigate the whole Source Control panel like this using direction keys (Up, Down, etc.), which means you can select files, use Left/Right to show/hide sections like "Staged Changes", and access more commit options by highlighting that box then using Tab to move inside it.
Okay, adding my answer found in the following issue, slightly modified:
Ensure that scm.focus command works in all cases
Use this keybinding:
{
"key": "alt+e", // whatever keybinding you want
"command": "extension.multiCommand.execute",
"args": {
"sequence": [
"workbench.scm.focus",
"list.focusFirst",
"list.select"
]
},
}
and the macro extension multi-command.
This works whether the scm view is open or not, whether something is already focussed in the scm view or whether a text editor is focussed.
So just the one keybinding, no need to Home and Enter whether a scm file has focus or not.
Keyboard Shortcuts: "Source control:Focus on Source Control View"

VSCode "Quick Open" menu alters "recently used" ordering too eagerly

When I step through the the VSCode Quick Open menu, I want it not to automatically switch between editors until I've selected the file I'm interested in (and hit enter). But with a recent (April?) change to VSCode, it automatically shows me each file as I step through the menu. How can I disable that behavior?
Here's my motivation, for those who are interested:
One of the (common?) ways to use VSCode's "Quick Open" menu is to use it like the "last channel" button on a TV remote. I want to open one editor, then open another, and then quickly toggle back and forth between the two. Since they are my current and most-recent editors, they should appear at the top of the Quick Open Menu, so toggling between them is fast.
This used to work just fine, but a recent (April?) change to the Quick Open menu seems to have broken this functionality. Now, it automatically activates the editor for every file that I step through in the menu, changing my "most recent" ordering. It can no longer be used like a "last channel" button.
Here's a short video demonstrating the problem. Here, I'm starting with one.txt. I want to select five.txt via the Quick Open menu, and then quickly toggle between the two. But it opens all the other files along the way!
(In fact, if you watch closely, the behavior is even weirder: It doesn't show me the currently selected file -- it opens the editor for each file as it becomes UN-selected. Maybe this is just a bug?)
FWIW, here are the the relevant parts of my keybindings.json, to make it clear which commands I'm referring to:
// keybindings.json
[
// Trigger quick open menu and pre-select the previously used editor.
// (With either cmd+left/cmd+right)
{
"key": "cmd+left",
"command": "workbench.action.quickOpenPreviousRecentlyUsedEditorInGroup",
"when": "!inEditorsPicker"
},
{
"key": "cmd+right",
"command": "workbench.action.quickOpenPreviousRecentlyUsedEditorInGroup",
"when": "!inEditorsPicker"
},
// Once the menu is open, scan through the choices.
// (Forward with cmd+right, backward with cmd+left)
{
"key": "cmd+left",
"command": "workbench.action.quickOpenNavigatePreviousInEditorPicker",
"when": "inEditorsPicker && inQuickOpen"
},
{
"key": "cmd+right",
"command": "workbench.action.quickOpenNavigateNextInEditorPicker",
"when": "inEditorsPicker && inQuickOpen"
}
]
The issue is that my chosen key binding conflicts with a hard-coded key binding in VSCode. A workaround is to just use a key other than the right arrow.
Explanation here: https://github.com/microsoft/vscode/issues/98479#issuecomment-633378132

How to reset Visual Studio Code key bindings?

I have been experimenting with my vs-code key bindings.
I would like to reset the key-bindings to the original settings.
How do I do that?
I am on Linux Mint 18.
I tried removing all the records from the keybindings.json
Version 1.34.0 seems to have the settings at a slightly different location:
Click File > Preferences > Keyboard Shortcuts
There is a triple-dot (...) at the top-right hand corner. Click on that and select "Show User Keybindings"
Delete your listed keybindings
Here are the steps to reset the keybindings in VS code.
Click File > Preferences > Keyboard Shortcuts or Press Ctrl+K Ctrl+S
Then, click on keybindings.json
From keybindings.json remove the custom bindings you want to reset.
It seems newer versions of VSCode (>1.33 for Mac) doesn't have a direct link to keybindings.json anymore, as this answer shows. However, there is an option to reset user defined keybindings without mess with files.
Go to the Keyboard shortcuts settings:
There, find the setting tagged as "User". If you click on it with the right mouse button, a context menu will show the option "Reset Keybinding":
This action is gonna reset the selected keybinding and tag it with "Default" again.
first go file > preferences > keyboard shortcuts
you can see all key that you change whit click on triple-dot
or put ( #source:user ) in search bar
now you can right click on which one that you want to reset and select ( reset keybinding )
If you had installed the Keybinding as an Extension e.g Sublime or IntelliJ IDEA Keybindings, simple go to Extension and disable or uninstall it and you would have your default keybinding.
Do we need another answer? Maybe not, but every year or so I find myself sifting through the information on this page, so to make it quicker next time, here are some notes:
To find the location of the settings, you can look for a button/link to the json file located somewhere in Preferences. However, I have found it easier to find the json files on my hard drive than to locate that button/link inside the app (some users report that the button/link is missing in some versions of the app). If your OS does not allow you to search through system files, open a terminal session and type $ locate keybindings.json.
If you can memorize shortcuts, a typical default shortcut that can take you to the button/link is CMD+SHIFT+P. This shortcut opens a box below the main toolbar and you can type "json" in that box to find a button/link to the json file.
General settings are in settings.json
Keyboard settings are in keybindings.json
MacOS: ~/Library/Application Support/Code/User/
Example of keybindings.json
// Place your key bindings in this file to override the defaultsauto[]
[
{
"key": "cmd+r cmd+r",
"command": "workbench.action.reloadWindow",
"when": "isDevelopment"
},
{
"key": "cmd+r",
"command": "-workbench.action.reloadWindow",
"when": "isDevelopment"
},
{
"key": "shift+cmd+c shift+cmd+c",
"command": "workbench.action.terminal.openNativeConsole",
"when": "!terminalFocus"
},
{
"key": "shift+cmd+c",
"command": "-workbench.action.terminal.openNativeConsole",
"when": "!terminalFocus"
},
{
"key": "ctrl+cmd+c",
"command": "editor.action.commentLine",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "ctrl+shift+alt+cmd+[Minus]",
"command": "-editor.action.commentLine",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "shift+cmd+c",
"command": "editor.action.blockComment",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "shift+alt+a",
"command": "-editor.action.blockComment",
"when": "editorTextFocus && !editorReadonly"
}
]
Note that mapping a key combination that is already in use may result in conflicts. So the best approach is to first remap that default binding to something else. In the above, for instance, the "-" that prefixes "-editor.action.blockComment" serves to suppress the default binding. Thus, you may find that your key bindings are best set in pairs (unless your preferred combinations are sufficiently rare).
Example of settings.json
{
"workbench.colorTheme": "Solarized Light",
"window.zoomLevel": 4,
"workbench.activityBar.visible": false,
"workbench.statusBar.visible": false,
"editor.quickSuggestions": false,
"editor.suggest.snippetsPreventQuickSuggestions": false,
"editor.acceptSuggestionOnCommitCharacter": false
}
Try this documentation page about key binding in VSCode:
https://code.visualstudio.com/docs/getstarted/keybindings
Open a directory that contains user settings (https://code.visualstudio.com/docs/getstarted/settings) and try to remove user key bindings file.
On VS Code version 1.42.1 on Mac you can find a button that opens the Keyboard shortcuts JSON file on the top right corner of the keyboard shortcuts screen which you can open from Code -> Preferences -> Keyboard Shortcuts
For the newer version of VSCode (Version: 1.43.1), you can open the keybindings.json file from the Command Palette (⇧⌘P OR Ctrl+Shift+P) with the Preferences: Open Keyboard Shortcuts (JSON) command.
Once you delete all the data in the keybindings.json file you should get rid of any changes you made to keyboard shortcuts for your installation. Everything would be set back to default.
Reason: The first line in keybindings.json file is a comment // Place your key bindings in this file to override the defaultsauto[], which means if you delete all what is there you'll get the VSCode defaults. (Ref https://code.visualstudio.com/docs/getstarted/keybindings#_advanced-customization)
You can find all information on keybindings here.
For future searchers, since this question refers to Linux, even if the keybindings.json file is moved again one can always just use locate to find it:
$ locate keybindings.json.
Chances are, you will only have one, and if you have more, it will be clear where it is, as it is somewhere inside Code folder.
For example, as of today, mine is here: /home/auser/.config/Code/User/keybindings.json
Going directly to the file, will give you the opportunity to keep what you want and remove what you think might be the problematic setting.
For VSCode Version 1.35.1, which I'm using, one can directly open the keybindings.json file using the button that looks like {} on top-right corner of "Keyboard Shortcuts" Tab's title bar:
Picture showing {} button in top-right corner
Cleaning content of this file cleans all user defined key bindings.
In the latest version, the setting json file is with highlighted button.
I deleted everything in there and it seems to reset all keys.
User setting file
If you are on a Mac, press and hold command while hitting the k and s keys. Then click the icon on the top right with the three circles and press "Show User Keybindings". Then, hit command + delete while highlighting over the keybinding you want to delete.

VSCode: How to perform "Clear Search Results" in "Find in Files" without using the mouse?

After I search through files in the project directory with Command-Shift-f, the files that are opened are have the search string highlighted. The only way to unhighlight them seems to be to clear the search results. But typing "Esc" doesn't do that. I have to click the top-right corner "Clear Search Results" button. Is there a keyboard shortcut for that?
Update:
Now you can add keybindings for these commands. Example:
{
"key": "cmd+escape",
"command": "search.action.clearSearchResults",
"when": "editorTextFocus"
}
The best way to find these commands is by searching in the Keybindings editor. The others are search.action.refreshSearchResults and search.action.collapseSearchResults.
Original answer:
Not yet, but there is an open feature request to allow it: https://github.com/Microsoft/vscode/issues/23558
No, there's no default keyboard shortcut for "Clear Search Results."
⇧⌘E (among others) unhighlights search matches in the editor but doesn't clear search results.
To make Esc clear search results, add the key binding rule below to your keyboard shortcuts file.
{
"key": "escape",
"command": "search.action.clearSearchResults",
"when": "hasSearchResult"
}
Instuctions: Key Bindings for Visual Studio Code: Advanced Customization
Side effect: Since this rule conflicts with Esc for closeFindWidget, you must use ⇧Esc to close the find widget when you also have search results. (There may be other conflicts. I don't know.)
Note: This command works when the editor has focus, but clearing search results (either with the mouse or keyboard) moves the focus to the search input box. You can use ⌘1 to move the focus back to the editor.
Seems they added a Search: Clear command (which you will need to set your own shortcut for), but it only clears entries in the side panel, and only if you have actually run the search.
My workaround for this for a simple search is Ctrl+F Backspace Esc. That is, press hotkeys for a new search, which automatically highlights the old value, then delete that search and escape.
A long shortcut :-) is:
Select find-in-files string: ⇧⌘F
clear the string: ⌫
clear the results: ↵
close the panel: ⌘J
(Mac ⌘ → Windows Ctrl).
This isn't precisely what the OP asked for but it is closely related. The idea is to fully undo the effects of pressing the shortcut for "Search: Find in Files", which means activate Explorer and focus the text editor.
{
"key": "shift+escape",
"command": "extension.multiCommand.execute",
"args": {
"sequence": [
"workbench.view.explorer",
"workbench.action.focusActiveEditorGroup"
]
},
"when": "searchViewletVisible"
}
This requires the multi-command extension.

How to disable VS Code minimap in Windowed mode?

I did the following in Visual Studio Code:
settings.json => "editor.minimap.enabled": true
Open 2ed files side by side (windowed mode)
Minimap exists in both windows
This takes up too much room, but I still want to use the Minimap when I'm editing a single file in a single window. Is there a way to have the Minimap enabled for a single file, but disabled in side-by-side "Windowed" mode?
Toggle minimap command has been added since vscode 1.16. Hit command + shift + p and select View: Toggle Minimap.
There is no way to do this in VS Code. Currently there is only the "editor.minimap.enabled": false setting which can be true or false and either always enables the minimap or always disables it.
Unfortunately, as shown in this issue, there is also no "toggleMinimap" command to assign to keybindings.
You might find this extension useful, though, as it can be used to create a toggle minimap command:
settings:
"settings.cycle": [
{
"setting": "editor.minimap.enabled"
}
]
keybindings.json:
{
"key": "ctrl+shift+t",
"command": "settings.cycle.workbench.colorTheme",
"when": ""
}
Simplest way is go to:
View -> Toggle Minimap
Update:
In newer versions:
View -> Show Minimap
To remove/disable/hide VS Code Minimap,
Go to the View tab and uncheck this: View > Show Minimap
1) Go to File -> Preferences -> Keyboard Shortcuts
2) type in "View: minimap"
3) right click and add a key binding.
I like to use ctrl+m ("m" for minimap)
If there are existing key bindings, you can use another one, or click the existing one(s) listed, then right click them and remove the binding before repeating steps 2 and 3 above.
New option available,
View-> Show minimap (uncheck)
In Visual Studio Code Version 1.41.1. Go to
Files >> Preferences >> Settings
Select
Text Editor >> Minimap >> Uncheck Enabled checkbox
I didnt find "minimap", instead I found:
[Options]>>[Text Editor]>>[All Languages]>>[Scroll Bars]>>Behavior>>"Use map mode for vertical scroll bar"
I am not able to embed image yet, check link