Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?


Failed to load latest commit information.
Latest commit message
Commit time
March 19, 2019 10:18
September 12, 2016 14:43
September 12, 2016 14:03

Call for Maintainer

Dear users of this plugin! Sorry, but I no longer maintain it! If someone of you are interested in maintaining it, please, contact me and I will add you as a contributor.


AutoSave - automatically saves changes to disk without having to use :w (or any binding to it) every time a buffer has been modified or based on your preferred events.

Inspired by the same feature in RubyMine text editor.

By default AutoSave will save every time something has been changed in normal mode and when the user leaves insert mode. This configuration is a mix between "save as often as possible" and "try to avoid breaking other plugins that depend on filewrite-events".


Use vundle or download packaged version from


AutoSave is disabled by default, run :AutoSaveToggle to enable/disable it.


Enable on Startup

If you want the plugin to be enabled on startup use the g:auto_save option.

" .vimrc
let g:auto_save = 1  " enable AutoSave on Vim startup

It's also possible to override global g:auto_save value individually per buffer or window. For example, if you have auto save enabled globally, you can opt out some files. And vice versa, opt in some files, when you have auto save disabled globally.

let g:auto_save = 0
augroup ft_markdown
  au FileType markdown let b:auto_save = 1
augroup END


AutoSave will display on the status line on each auto-save by default:

(AutoSave) saved at 08:40:55

You can silence the display with the g:auto_save_silent option:

" .vimrc
let g:auto_save_silent = 1  " do not display the auto-save notification


The events on which AutoSave will perform a save can be adjusted using the g:auto_save_events option. Using InsertLeave and TextChanged only, the default, will save on every change in normal mode and every time you leave insert mode.

" .vimrc
let g:auto_save_events = ["InsertLeave", "TextChanged"]

Other events you may want to use:

  • TextChangedI will save after a change was made to the text in the current buffer in insert mode.
  • CursorHold will save every amount of milliseconds as defined in the updatetime option in normal mode.
  • CursorHoldI will do the same thing in insert mode.
  • CompleteDone will also trigger a save after every completion event.

Some of these commands may not be available, depending on your Vim installation. See the autocommands overview for a complete listing (:h autocommand-events).

Warning! Be advised to be careful with the updatetime option since it has shown to cause problems when set too small. 200 seems already to be too small to work with certain other plugins. Use 1000 for a more conservative setting.

(Pre/Post)save Hooks

If you need an autosave hook (such as generating tags post-save, or aborting the save earlier) then use g:auto_save_postsave_hook or g:auto_save_presave_hook options:

" .vimrc

" This will run :TagsGenerate after each save
let g:auto_save_postsave_hook = 'TagsGenerate'

" This will run AbortIfNotGitDirectory function before each save
let g:auto_save_presave_hook = 'call AbortIfNotGitDirectory()'

" Example hook from vim-auto-save-git-hook plugin
function! AbortIfNotGitDirectory()
  if ...
    let g:auto_save_abort = 0
    let g:auto_save_abort = 1

Write to All Buffers

By default only the current buffer is written (like :w). You can choose that all buffers are written on autosave using the g:auto_save_write_all_buffers option (like :wa).

" .vimrc
let g:auto_save_write_all_buffers = 1  " write all open buffers as if you would use :wa


The doc/auto-save.txt is a converted version of the Don't edit it directly. Instead install the md2vim and run the script.

Contribution or Bug Report

Development is made in 907th/vim-auto-save repo. Please, report any bugs and/or suggestions there. Any contrubution is welcomed!


Distributed under the MIT License (see LICENSE.txt).

Copyright (c) 2013-2021 Aleksei Chernenkov


A Vim plugin which saves files to disk automatically.