Refresh Visual Studio Code list of files - visual-studio-code

Visual Studio Code (Version 0.10.11, on OSX) does not refresh the files in a folder. Is there any way to force it to refresh. Currently I have to close and reopen the whole program.

EDIT: In the meanwhile a reload button has been added to the file explorer widget.
Use the workbench.action.reloadWindow command.
Go to File -> Preferences -> Keyboard Shotcuts and define a shortcut for this command. On my system it's placed on Ctrl+F5. The entry in keybindings.json looks like this:
{
"key": "ctrl+f5",
"command": "workbench.action.reloadWindow",
"when": "editorTextFocus"
}

If you hover over the workspace root in the navigator, four icons appear to the right of it. The third of those icons, a circular arrow, is Refresh -- it reloads the file list.

You can use the command palette to reload the window:
Open the command palette with View > Command Palette... (or Shift+Cmd+P on OS X)
Type reload window and press enter

You shouldn't need to reload the entire window, just the folder list. Reloading the window will kill terminals, lose undo history, etc. You can do this using the refresh button in the explorer (second from the right):
If you find you need to do this a lot you can add a keybinding for it, for example:
{
"key": "ctrl+f5",
"command": "workbench.files.action.refreshFilesExplorer"
}

Ran across this today with VS Code 1.13.0 and in Keyboard Shortcuts I see
workbench.files.action.refreshFilesExplorer

To reload a single file:
⇧⌘P
type "Revert File"
On Windows:
Ctrl + Shift + P
type "Revert File"
Tested in VSCode v1.18.1 on Windows

If you use the SFTP extension you can do this for refreshing the SFTP:EXPLORER list (tested on Windows with VSC 1.40.2):
File => Preferences => Keyboard Shortcuts => Search for: refresh
Then you have to find "Refresh / sftp.remoteExplorer.refresh" in the result list.
Click the entry, then click the plus sign before the entry, then press your desired shortcut and hit "enter". I took "Ctrl + Alt + F5" because this has not been used for other commands already.

Right-Click your sln (Will say 0/n solutions)
In the bottom row of dialog it will say reload project solutions.
If it's not present, then it was just reloaded most likely. Try to run build again.

When search.maintainFileSearchCache option is enabled I started to find the files with I'm using Ctrl-P shortcut

"Ctrl + Alt + R" on v 1.27.1 as of 9/11/18

Related

How I can make `ctrl + click` to go to definition in visual studio code editor for mac OS?

How I can make ctrl + click to go to definition in visual studio code editor for mac OS? Now it is F12 which is using my mac for show desktop.
First and foremost, please note that in VS Code for macOS, the familiar Ctrl + click from Windows / Linux operating systems has been replaced with ⌘ + click (i.e.: "command + click"). Try that first before proceeding any further as that shortcut should work out of the box without any special modifications.
However, if the above still doesn't work for you then try fixing the problem by editing your settings.json file. To do that, press F1, type settings json, then click Open Settings (JSON), and then do one of the following:
To use ⌘ + click as your "Go to definition" shortcut, ensure the following line exists in your JSON settings:
"editor.multiCursorModifier": "alt",
What this does is it explicitly sets VS Code's "add another cursor" shortcut to option + click (try it out for yourself!), thus freeing up ⌘ + click to be used for the "Go to definition" operation.
Conversely, to use option + click as your "Go to definition" shortcut instead, add:
"editor.multiCursorModifier": "ctrlCmd",
Note: the above line will actually set the "add another cursor" shortcut to ⌘ + click (not Ctrl + ⌘ + click, as implied by the JSON value).
Settings > User > multiCursorModifier must be set to alt (default), so the ctrl/cmd will be available to go to definition.
Documentation:
The modifier to be used to add multiple cursors with the mouse. The Go To Definition and Open Link mouse gestures will adapt such that they do not conflict with the multicursor modifier.
In gear icon/keyboard shortcuts, search for f12 .
Right-click on the "Go to Definition" entry and chose "Remove Keybinding".
Note that will put a new entry at the end of your keybindings.json like:
{
"key": "f12",
"command": "-editor.action.goToDeclaration",
"when": "editorHasDefinitionProvider && editorTextFocus && !isInEmbeddedEditor"
}
Note the "-" sign before the command, that removes that keybinding.
Now copy and paste that whole entry below it (with a comma at the end of the previous entry):
{
"key": "f12",
"command": "-editor.action.goToDeclaration",
"when": "editorHasDefinitionProvider && editorTextFocus && !isInEmbeddedEditor"
},
{
"key": "cmd+enter",
"command": "editor.action.goToDeclaration",
"when": "editorHasDefinitionProvider && editorTextFocus && !isInEmbeddedEditor"
}
Remove the minus sign and assign whatever keybinding you like. Alternatively, go back to shortcuts file, search for "Go to Definiton" and click the pencil icon to use its interface to create a new keybinding.
Note that Ctrl-Enter is used in many contexts so you might have an unexpected conflict using such a common keybinding.
In my case, I checked this in the settings
Settings > User > multiCursorModifier must be set to alt (default)
By default, it is set to alt only
I just did right-click on VS code and quit and open it again to resolve the issue.
Hope it may help someone!
I was facing similar issue with my python code though it was working fine with my JS code. I have to install Python extension developed by Microsoft & it worked.
In my case cmd+click wasn't working when i was connected to a remote machine via remote ssh, but worked fine locally. Installing language extensions(C/C++ Extension Pack in my case) on a remote solved the issue for me.
go to .flowconfig file and change the required the version(it is the bottom)
I found what turned off this feature.
Go to Settings and search for "ctrlCmd". There are two settings that overrode the command: Editor: Multi Cursor Modifier and List: Multi Select Modifier. I turned both of these off because I don't use them, and I got my control-click to definition back.
I know those settings are useful to some. The default for both is alt-click. I presume an extension or an update changed something.
For me Ctrl ^+click / Cmd ⌘+click was not working, although F12 was. So, tried with option ⌥+click, which worked.
In my vscode, this problem is proved to be caused by some extensions. After removing one extension(I forget the name, should be related with vscode), it works.

VSCode split editor move file instead of copy

I have recently moved to Visual Studio Code and have a question that I have found an answer for.
When I split the editor it shows the focused file on both sides of the split.
I want the focused file to be moved with the split rather than showing a duplicate view.
Is there a setting or an extension that I can use to do this split / move?
Try the Move Editor into next Group command:
{
"key": "ctrl+cmd+right",
"command": "workbench.action.moveEditorToNextGroup"
}
on mac default shortcut is:
control+command+ -> or <- arrow ;-)
on Windows, vscode v1.59.0
To move file to right side
click on file to focus:
ctrl+alt+right arrow
To move file to left side
click on file to focus:
ctrl+alt+left arrow
Personally, i always used ctrl+enter combination to open the next file in the side editor. So far, it is the most recommended way that I always use.
In Ubuntu (20.04) the keybindings are the same as in windows:
ctrl + alt + right and ctrl + alt + left however gnome blocks these keybindings. In order to liberate them, run the following in the terminal which changes your gnome settings:
gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-left "[]"
gsettings set org.gnome.desktop.wm.keybindings switch-to-workspace-right "[]"
After that, it should work.
See also:
Some VSCode Keybindings not working in Ubuntu
And:
https://askubuntu.com/questions/1041914/something-blocks-ctrlaltleft-right-arrow-keyboard-combination
https://github.com/microsoft/vscode/issues/6197
Windows: Ctrl-Alt-X
File -> Preferences -> Keyboard shortcuts.
Search "move editor" for wider set of options, or as in the attached image search "move editor into"

Open current editing file in explorer tree

I'm wondering if there is a shortcut for VS Code that highlights in solution explorer tree current opened file. Like we have in Visual Studio:
Alt + Shift + L
Couldn't live with no complete answer, so figured out the following:
Without a direct keyboard shortcut:
Open the command palette via Cmd-Shift-P (or Cmd+P then >) and type Files: Reveal Active File in Side Bar.
This reveals the active file in the side bar similar to Visual Studio's Alt+Shift+L
Then, take the above and map a keyboard shortcut to it:
Open keyboard shortcut preferences file via Cmd-Shift-P followed by Preferences: Open Keyboard Preferences File.
Add in the following (taking Visual Studio's lead, I've personally mapped it to Alt+Shift+L, but map to what you want).
// Place your key bindings in this file to overwrite the defaults
[
{
"key": "shift+alt+l",
"command": "workbench.files.action.showActiveFileInExplorer",
},
]
Note that it's not as good as Visual Studio, Atom, etc. in that you can't then navigate with arrow keys in the tree (arrow keys navigate the active file contents), but I guess I'll eventually figure out how to do that.
#Tomoyuki Aota points out that you can do the following to navigate with arrow keys:
After Files: Reveal Active File in Side Bar, press Ctrl+Shift+E (Show
Explorer). After that, I can navigate the files in the explorer by the
arrow keys.
I don't think there's a command for that, but there is a shortcut to enable/disable revealing the current file as you open it:
"explorer.autoReveal": true
Try this:
Together with #Rob's correct answer:
"explorer.autoReveal": true
then Ctrl-Shift-E (Show explorer) focuses that file in the explorer and the arrow keys will navigate up/down/left/right like any list. This works even if the explorer is closed prior to the Ctrl-Shift-E.
Ctrl-Shift-E has the added bonus in that it will toggle focus between the highlighted file and its editor as well.
For mac, use Cmd-Shift-E
Right-click the file tab (not necessarily current one) and click "Reveal in Side Bar".
I was able to achieve this by customizing the workbench.files.action.focusFilesExplorer command with keybinding Alt + shift + L
Open the Keyboard Shortcuts ctrl + K + shift + S
search for focusFilesExplorer command & customize
Provide your keybindings that you are used to - I set mine to Alt + Shift + L
F1 then type "reveal" also works from in VS Code, at least for me.
It looks like the actual version of VS Code offers a command for this feature now.
In the settings, type revealInExplorer in the search bar to find the command. There is no default keybinding, so just put your own. Works like a charm!
Download the open in browser extension, that's it.
Right click > Open in primary/secondary browser function appears, and the ALT+B / ALT+SHIFT+B shortcuts become available.
Had a similar case and ended up here looking for help.
I opened a file in "preview" mode after clicking a link in a .md file and wanted to know where this opened file was located in the project.
I found this button in the upper right corner of VS Code which was exactly what I wanted:
It's called "show source"
Also check "Explorer: Auto Reveal Exclude" patterns in VS Code settings. Files that fit any of the patterns will not be auto revealed in the Explorer tree.

OS X: cycle between windows in visual studio code

I'm trying desperately to figure out how to cycle through windows in Visual studio code. In Finder, there is a menu item Cycle Through Windows which I use frequently. However, this seems to be a Finder option. So I looked through the global shortcuts (since the requirement is probably the same for many applications) and assigned the Move focus to next window to shift-cmd-F1. This works in Finder and Text Editor, but not in Visual Studio Code. I checked if the key binding is overridden in VSC but I don't think so.
Has anyone got this figured out and can help me?
edit: just found that this is a global shortcut under System Settings > Keyboard > Shortcuts > Move focus to the next window. Unfortunately, Visual Code doesn't use it.
I added the following shortcut to keybindings.json
{
"key": "alt+tab",
"command": "workbench.action.quickSwitchWindow"
}
workbench.action.quickSwitchWindow does exactly what I want and it has no default shortcut enabled (on a spanish keyboard at least).
So, finally found the solution: Though for some reason the system-wide shortcut for Move focus to next window does not work, there is another shortcut which does: shift+cmd+~ :)
Found it here: https://support.apple.com/en-us/HT201236
command ⌘ + ` is working nicely for me on macbook Pro.
You can use Switch window from command palette (command: workbench.action.switchWindow). The default shortcut is Ctrl + w.
It lists all the open windows for you to select and go.
It's improved further.
The newest version of Visual Code (1.55.2) has window switching enabled by default.
The hot key is Control+W (⌃+W), which will bring down a command window for you to select which window to jump to.
shift ⇧ + command ⌘ + ~ works for me unless I am in full screen mode. Alternatively, you can use the following shortcuts in full screen:
shift ⇧ + command ⌘ + p then type "Switch Window".
There seem to be tons of ways to cycle windows. I finally found one that worked for me:
shift + cmd + "{" or "}"
If you go to "window" in the application you'll see menu items for "Next Document" and "Previous Document".
Just FYI, the shortcut for Ubuntu(Gnome 3) is alt + ` for switch between visual studio code (or other applications) windows.
Personally, I rather use quickOpenRecent instead of quickSwitchWindow because it allows me to quickly switch between the last used window and the current one (stacked cycling instead of sequential). I have the following mapped to alt+tab:
{
"key": "alt+tab",
"command": "workbench.action.quickOpenRecent",
"when": "!inRecentFilesPicker"
},
{
"key": "alt+tab",
"command": "workbench.action.quickOpenNavigateNextInRecentFilesPicker",
"when": "inQuickOpen && inRecentFilesPicker"
},
{
"key": "shift+alt+tab",
"command": "workbench.action.quickOpenNavigatePreviousInRecentFilesPicker",
"when": "inQuickOpen && inRecentFilesPicker"
}
Set the Quick Switch Window... keyboard shortcut to command+N
is a better work around for me.
Go to the menu Code/Preferences/Keybord Shortcuts and search for quickSwitchWindow
To cycle through windows that are in the same desktop, I use :
shift + command + `
Mac OS 12.2. Azerty, and VS Code 1.64.2
None of cmd+` cmd+shift+F1 or shift+cmd+~ work for me but ctrl+cmd+\ does.
I'm using a UK Windows keyboard layout - not sure if that affected it..
Edit: I originally found that cmd+\ was working but having restarted VS Code that changed to ctrl+cmd+\ - very odd
if you know how to open keybodard shortcuts from vscode,
type "switch" in input box which has a placeholder "Type to search in Keybindings". you will see "switch window...".
i am using macbook and ^ + W is an default shortcut key for switching windows in between.
I'm running macOS Monterey, control^ + w worked for me.
in VsCode press Ctrl+Shift+P and search Open next editor and click on Setting button and change it to your shortcut keys!

How can I change keyboard shortcut bindings in Visual Studio Code?

Using Visual Studio Code what is the procedure to:
Remap a built in command's keyboard shortcut. For example, say, Open File (default is Ctrl+O, it's unlikely that anyone would actually change this, but the same process should probably apply for any built in shortcut).
Remap an extension command's keyboard shortcut, say the Bookmark extension's toggle-bookmark (default Ctrl+Alt+K)
IN 2015, this involved editing configuration JSON files, but I don't know which one, or how. In 2021 there's a new UI, how do I find it?
Click File -> Preferences -> Keyboard shortcuts. Use the tab that opens up to edit and find available key bindings and assign them.
Historical Note: In very early versions of visual studio code, you would Click File -> Preferences -> Keyboard shortcuts and you would get JSON like this keybindings.json:
// Place your key bindings in this file to overwrite the defaults
[
{ "key": "ctrl+o", "command": "workbench.action.files.openFile" },
{ "key": "ctrl+alt+k", "command": "bookmarks.toggle",
"when": "editorTextFocus" }
]
But now in 2021 versions, there is a proper GUI, which is great because the json editing method was error prone and hard to discover.
The json editor feature has been moved to a new icon:
If you want to change the advance settings of keyboard shortcut such as when then you can follow these steps:
Update:(Thanks #phdoerfler for pointing it out that icon has changed)
File->Preferences->Keyboard Shortcuts
Click on icon on top right corner that says "Open Keyboard Shortcuts(JSON)" to open JSON version and place the keybinding.
You can find this in Documentation here.
The way to open the JSON file changed yet again in a recent version.
You need to click the middle of the three buttons in the tab bar.
You only need to do that if the change you need isn't possible on the normal settings screen.
On Windows:
go to File -> Preferences -> Keyboard shortcuts,
or press Ctrl+K, then Ctrl+S,
or edit %UserProfile%\AppData\Roaming\Code\User\keybindings.json file
On Mac:
go to Code -> Preferences -> Keyboard shortcuts,
or press Cmd+K, then Cmd+S
Keep in mind you can type things like shift ctrl c in the Search input in Keyboard Shortcuts panel to find commands by their keybindings.
Here you can find documentation which among other stuff contains also information about what When conditions you can use.
The latest version of Visual Studio Code 1.11.0 provides a rich and easy keyboard shortcuts editing experience using a new Keyboard Shortcuts editor. Read more here on their website.
I will not repeat others answers! And if like me! You get to install a mapping extension!
My prefered is Visual studio keys map
And the question would have been how you select it! How you change it ! Can we install multiples! And select between them!
First here some useful links about key binding and shortcuts
https://code.visualstudio.com/docs/getstarted/keybindings
https://code.visualstudio.com/docs/getstarted/tips-and-tricks
And before any, know that you can get to the keymaps extension by using the bottom left settings button for settings context menu! As in the picture bellow:
or through file>Preferences>keymap
Then you have to install one of the keymaps
The thing to know is that it will take place and make the changes right away!
What if you install another?
The new one take over! Or some mix! I couldn't tell!
And you may have problems!
How you change from one to another?
Remove the old ! remove the new one! And install it again! That's the way that i found it works! Disabling and reenabling didn't work!
And better always let only one installed at a time!
Unfortunitly as by Now 2020-05-08 no options to select between keys mapping exist!
Undo a keymap
Just remove! You may need to restart the editor!
Restart the editor
Also note that if you uninstalled all and reinstalled the one you want! And changes didn't take place! Close the editor and reopen it! That's help!
I hope that's help and may be save you some searching time!
And sure in the future we will have better handling! As vscode is just keeping getting more awesome and awesome! So an option to select and better handling will is expected to be added! And we will wait for it!
FYI on mac the keybindings.json file sits there:
/Users/your_user_name/Library/Application Support/Code/User/keybindings.json
ctrl + shift + p
Type open keyboard shortcut in the search bar
It opens keyboard Shortcuts. Here you can customize shortcuts.
(For extra info follow from 4th point)
There at the top right corner click on open keyboard shortcuts (JSON) (Refer to the image)
There you can modify the key, command, and when. That is also cool.
I tried
{
"key": "ctrl+a",
"command": "workbench.action.terminal.selectAll",
"when": "terminalFocus && !isMac"
}
by this now I can select all in vscode terminal
On Windows: Ctrl + K, then S
On Mac: ⌘ + K then ⌘ + S
This opens Keyboard Shortcuts Editor. It's searchable/filterable by either shortcut name or the key combination itself (example: type "ctrl" to see all bindings to the CTRL key.)
Image:
vscode search keyword shortcuts panel
Open Key Shortcuts from Preferences -> Keyboard Shortcuts
Search for the action in search field
Right click on one of the results and select "Show same keybindings"
Delete the conflicting key binding!