To use it, add the following to your vimrc, or create file ~/.vim/plugin/filechanged.vim (Unix) or $HOME/vimfiles/plugin/filechanged.vim (Windows) containing the script below, then restart Vim. au FileChangedShell * call FCSHandler(expand(":p")) function FCSHandler(name) endfunction You can easily customize this code to take whatever action you desire for the various values of v:fcs_reason, by setting v:fcs_choice (for example, you could reload the buffer if the mode has changed). Based on discussion on the vim_use mailing list.
Attributes | Values |
---|
rdfs:label
| - File no longer available - mark buffer modified
|
rdfs:comment
| - To use it, add the following to your vimrc, or create file ~/.vim/plugin/filechanged.vim (Unix) or $HOME/vimfiles/plugin/filechanged.vim (Windows) containing the script below, then restart Vim. au FileChangedShell * call FCSHandler(expand(":p")) function FCSHandler(name) endfunction You can easily customize this code to take whatever action you desire for the various values of v:fcs_reason, by setting v:fcs_choice (for example, you could reload the buffer if the mode has changed). Based on discussion on the vim_use mailing list.
|
Version
| |
dbkwik:vim/property/wikiPageUsesTemplate
| |
Previous
| |
Category
| |
Author
| |
Subpage
| |
Complexity
| |
Created
| |
ID
| |
NEXT
| |
abstract
| - To use it, add the following to your vimrc, or create file ~/.vim/plugin/filechanged.vim (Unix) or $HOME/vimfiles/plugin/filechanged.vim (Windows) containing the script below, then restart Vim. au FileChangedShell * call FCSHandler(expand(":p")) function FCSHandler(name) let msg = 'File "'.a:name.'"' let v:fcs_choice = if v:fcs_reason == "deleted" let msg .= " no longer available - 'modified' set" call setbufvar(expand(a:name), '&modified', '1') echohl WarningMsg elseif v:fcs_reason == "time" let msg .= " timestamp changed" elseif v:fcs_reason == "mode" let msg .= " permissions changed" elseif v:fcs_reason == "changed" let msg .= " contents changed" let v:fcs_choice = "ask" elseif v:fcs_reason == "conflict" let msg .= " CONFLICT --" let msg .= " is modified, but" let msg .= " was changed outside Vim" let v:fcs_choice = "ask" echohl ErrorMsg else " unknown values (future Vim versions?) let msg .= " FileChangedShell reason=" let msg .= v:fcs_reason let v:fcs_choice = "ask" echohl ErrorMsg endif redraw! echomsg msg echohl None endfunction You can easily customize this code to take whatever action you desire for the various values of v:fcs_reason, by setting v:fcs_choice (for example, you could reload the buffer if the mode has changed). Based on discussion on the vim_use mailing list.
|