Atom editor does not reload changed file

感情迁移 提交于 2020-06-10 02:08:07

问题


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 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


来源:https://stackoverflow.com/questions/35299663/atom-editor-does-not-reload-changed-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!