问题
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.
回答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.
回答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.
回答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
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
来源:https://stackoverflow.com/questions/35299663/atom-editor-does-not-reload-changed-file