vim-auto-save (GitHub) is a plugin auto-save your files. By default, it’s disabled until you :AutoSaveToggle it and status will be printed on screen like one of:
AutoSave is ON AutoSave is OFF
Behind the scene, it relies on CursorHold event:
When the user doesn’t press a key for the time specified with ‘updatetime’. Not re-triggered until the user has pressed a key (i.e. doesn’t fire every ‘updatetime’ ms if you leave Vim to make some coffee. :) See CursorHold-example for previewing tags.
This event is only triggered in Normal mode. It is not triggered when waiting for a command argument to be typed, or a movement after an operator.
While recording the CursorHold event is not triggered. q
It sets updatetime to 200, that is 200ms, this variable is also the interval of swap file written to disk.
Once a file is auto-saved, a message like the following is displayed:
(AutoSaved at 15:47:10)
It also provides some options like g:auto_save and g:auto_save_no_updatetime. So you can tell the plugin to turn on always, or not to mess around with your updatetime.
Personally, I don’t like using plugins like this, because I want to control by myself even a crash might make me curse. But that really doesn’t happen, at least I don’t remember any, the swap file is always recoverable for me, and I have never lost anything if I do have the swap files.
It’s written by Alexey Chernenkov under the MIT License, currently version 0.1.4 (2014-04-03)
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.