8

I'm looking for a way to refresh the content of a file opened in editor after it was changed by other tool.

For instance I'm using angular command line which makes changes to files but VS Code doesn't refresh the content after that and I can't see any of that. What's worse when I try to save the file, VS Code by default tries to save the old content upon the newer (asks before of course, but still its not what I'm looking for).

I didn't find any keybindings for refresh the editor's content. Maybe there are any extensions?

Thank you.

Jacek Dziurdzikowski
  • 2,015
  • 2
  • 13
  • 20
  • Check out this plugin https://marketplace.visualstudio.com/items?itemName=dotnetricardo.Reload – Michael Platt Sep 28 '17 at 18:53
  • 1
    Thank you but this extension unfortunately is about refreshing browser, Im looking for extension or built-in for refreshing an opened content of a file in the editor. – Jacek Dziurdzikowski Sep 28 '17 at 19:05
  • 1
    Ok what about changing the hotkey like this guy suggests in his answer? https://stackoverflow.com/questions/36333117/refresh-visual-studio-code-list-of-files – Michael Platt Sep 28 '17 at 19:08
  • Best answer is here: https://stackoverflow.com/a/42002990/908936 – razon Oct 22 '18 at 08:13
  • If https://github.com/microsoft/vscode/issues/186976#issue-1787728566 is upvoted 20 times, this will become possible because the feature will be moved to VSCode's backlog. – rokejulianlockhart Jul 04 '23 at 13:30

2 Answers2

4

It should reload itself automatically, but I had a machine that stopped auto-refreshing. I'd change the file externally (with vim or whatever), and the file I had in the editor wouldn't pop and refresh itself, which it used to do. It turned out to be a git-related extension. I disabled it, and autorefresh returned. If you haven't already, try it with extensions off.

Glen
  • 652
  • 2
  • 6
  • 12
  • 3
    Yes, it should reload and most of the the times it does in fact, but in some situations (I didn't recognized exactly when yet) it doesn't and those moments the option to reload it by key shortcut would be efficient at least... – Jacek Dziurdzikowski Sep 29 '17 at 08:52
  • 2
    On a Mac, I could force a refresh from the keyboard by hitting ctrl-tab twice, which switches to another open file and then switches back. I did this briefly before I discovered that the extension was preventing auto-refresh. Also, double-check that you haven't accidentally excluded this file type from auto-refresh by checking `files.watcherExclude` in preferences. – Glen Sep 29 '17 at 10:12
1

keybindings.json

  {
    "key": "ctrl+f5",
    "command": "workbench.action.files.revert",
  },

This will reload the focused file from disk.
(Warning: Any unsaved changes on the focused file will be lost.)

Lindsay-Needs-Sleep
  • 1,304
  • 1
  • 15
  • 26