Atom editor does not reload changed file
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.
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 fromEdit
>Init.Script
- Mac:
~/.atom/init.coffee
; open in Atom fromAtom
>Init.Script
- Windows:
%USERPROFILE%\.atom\init.coffee
; open in Atom fromFile
>Init.Script
The keymap.cson
file is located in/ can be opened from Atom via (from here):
- Linux:
~/.atom/keymap.cson
; open in Atom fromEdit
>Keymap
- Mac:
~/.atom/keymap.cson
; open in Atom fromAtom
>Keymap
- Windows:
%USERPROFILE%\.atom\keymap.cson
; open in Atom fromFile
>Keymap
SharpCoder
Updated on June 06, 2022Comments
-
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 over 7 yearsI can't understand why this is not the default behaviour. I think it is terribly dangerous: github.com/atom/atom/issues/13717
-
ronme about 7 yearsI think @Code-Apprentice was looking for an automatic way to do that
-
Danke Xie almost 7 yearstrue. 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 over 6 yearsThe keystrokes for this are the same as in many applications.
ctrl+w
thenctrl+shift+t
. -
lasec0203 about 6 yearsI'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 almost 6 yearsIn 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 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 almost 5 yearsEven more annoying is I don't find anything to even manually force file reload.
-
phil123456 almost 4 yearsprecisely why atom is the sublime text of the poor, what a pity
-
ctpenrose almost 4 yearsThis 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 almost 3 yearsi installed file watched but it didn't work
-
shieldgenerator7 almost 3 yearsNote: Don't forget to restart Atom after applying these changes
-
Code-Apprentice almost 3 years@shieldgenerator7 If you need help, feel free to post a question.