Atom editor does not reload changed file

17,945

Solution 1

According to https://discuss.atom.io/t/auto-reload-changed-files/8451/6, FileWatcher is an Atom package which will do what you want.

Solution 2

A simple solution that works:

1) Just close the file being edited

2) Click "File->Reopen Last Item" to re-open it

Bingo!

For Atom versions 1.29+, you can just click "Fetch" on the bottom-right corner of the editor.

enter image description here

Solution 3

In order to manually force the reload of a file, paste the following lines in your init.coffee file (from here):

atom.commands.add "atom-workspace", "custom:revert-to-disk", ->
  atom.workspace.getActiveTextEditor().buffer.reload() 

In your keymap.cson file, paste the following:

'atom-workspace':
  'f5': 'custom:revert-to-disk'

NOTE: Make sure you restart Atom after applying these changes.

Whenever a file has changed and is not automatically reloaded, go to the tab and press F5. The file is immediately reverted to the disk state without prompt. So be careful, any manual changes (if any) are also irrecoverably lost, but that is the purpose of any revert-to-disk-state functionality.

The init.coffee file is located in/ can be opened from Atom via (from here):

  • Linux: ~/.atom/init.coffee; open in Atom from Edit > Init.Script
  • Mac: ~/.atom/init.coffee; open in Atom from Atom > Init.Script
  • Windows: %USERPROFILE%\.atom\init.coffee; open in Atom from File > Init.Script

The keymap.cson file is located in/ can be opened from Atom via (from here):

  • Linux: ~/.atom/keymap.cson; open in Atom from Edit > Keymap
  • Mac: ~/.atom/keymap.cson; open in Atom from Atom > Keymap
  • Windows: %USERPROFILE%\.atom\keymap.cson; open in Atom from File > Keymap
Share:
17,945
SharpCoder
Author by

SharpCoder

Updated on June 06, 2022

Comments

  • SharpCoder
    SharpCoder almost 2 years

    I am using Atom editor on Windows 7. On the git shell when I run the command, git reset --hard , all the other editors reset/undo all the modified files. but if I am using ATOM editor, changes are retained. If I try to close the file in editor, Atom ask, file is changed, do you want to save the changes.

    How can I force Atom to undo changes when files are modified externally.

  • Ruggero Turra
    Ruggero Turra over 7 years
    I can't understand why this is not the default behaviour. I think it is terribly dangerous: github.com/atom/atom/issues/13717
  • ronme
    ronme about 7 years
    I think @Code-Apprentice was looking for an automatic way to do that
  • Danke Xie
    Danke Xie almost 7 years
    true. hard to even come up with these keystrokes. however, i doubt there is 'refresh' in atom. not worth the time to install any plugins to do this.
  • 7yl4r
    7yl4r over 6 years
    The keystrokes for this are the same as in many applications. ctrl+w then ctrl+shift+t.
  • lasec0203
    lasec0203 about 6 years
    I'm fine with this workaround, since I usually only have this issue with 1 file at a time. The keystroke @7yl4r commented, makes this even better.
  • trusktr
    trusktr almost 6 years
    In newer versions of Atom, re-opening the last file includes unsaved changes you had in that file, it does not reload the actual file from disk.
  • Ben Lachman
    Ben Lachman over 5 years
    @DankeXie The fetch button does a git fetch operation, it doesn't reload/revert the open file to the on-disk version.
  • 0xc0de
    0xc0de almost 5 years
    Even more annoying is I don't find anything to even manually force file reload.
  • phil123456
    phil123456 almost 4 years
    precisely why atom is the sublime text of the poor, what a pity
  • ctpenrose
    ctpenrose almost 4 years
    This is hardly worthy of a Bingo!. Further, Fetch will only work if the file is available in a remote repo. No Remote is shown even if you have a local git repo backing the file.
  • shieldgenerator7
    shieldgenerator7 almost 3 years
    i installed file watched but it didn't work
  • shieldgenerator7
    shieldgenerator7 almost 3 years
    Note: Don't forget to restart Atom after applying these changes
  • Code-Apprentice
    Code-Apprentice almost 3 years
    @shieldgenerator7 If you need help, feel free to post a question.