Text editor that updates file without prompting
Is there any console- or window-based text editor that automatically reloads file changed on disk without prompting anything?
Solution 1:
vim
can do that. Just add
set autoread
to your ~/.vimrc
. (Also check out the Tail Bundle plugin.)
The autoread
setting applies only certain events (which can be determined by checking the help text for timestamp
(:h timestamp
)). To make vim
load files more frequently, there are two decent options:
- Define a function which watches for changes.
-
Set an autocommand such as:
au FocusGained,BufEnter,BufWinEnter,CursorHold,CursorMoved * :checktime
This will reload whenever
vim
gains focus, you enter the buffer, move a cursor, idle the cursor. It won't change the current cursor position though.
emacs
can also do this, if you add to your .emacs
:
(global-auto-revert-mode t)
This doesn't watch for changes either, but the following should:
(global-auto-revert-tail-mode t)
This is supposed to work like tail -f
, according to the EmacsWiki.
Even if gedit
doesn't support this, I'm sure there are plenty of other GUI editors which do.
Sources:
- Can vim monitor realtime changes to a file
- How to have Emacs auto-refresh all buffers when files have changed on disk?