Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update documentation for #46 #48

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,19 @@ If you want the plugin to be enabled on startup use the `g:auto_save` option.
let g:auto_save = 1 " enable AutoSave on Vim startup
```

## Enable for Buffer

If you want the plugin to be enabled for a specific buffer use the `b:auto_save` option.

```VimL
" .vimrc
augroup todo
autocmd!
" enable AutoSave for todo buffers
autocmd filetype todo let b:auto_save = 1
augroup END
```

## Silent

AutoSave will display on the status line on each auto-save by default:
Expand Down
47 changes: 30 additions & 17 deletions doc/auto-save.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ CONTENTS *auto-save-content
3. Usage.........................................................|auto-save-usage|
4. Options.....................................................|auto-save-options|
4.1. Enable on Startup...........................|auto-save-enable_on_startup|
4.2. Silent.................................................|auto-save-silent|
4.3. Events.................................................|auto-save-events|
4.4. Postsave Hook...................................|auto-save-postsave_hook|
4.5. Write to All Buffers.....................|auto-save-write_to_all_buffers|
4.2. Enable for Buffer...........................|auto-save-enable_for_buffer|
4.3. Silent.................................................|auto-save-silent|
4.4. Events.................................................|auto-save-events|
4.5. (Pre/Post)save Hooks.....................|auto-save-(pre/post)save_hooks|
4.6. Write to All Buffers.....................|auto-save-write_to_all_buffers|
5. Development.............................................|auto-save-development|
6. Contribution or Bug Report...............|auto-save-contribution_or_bug_report|
7. License.....................................................|auto-save-license|
Expand Down Expand Up @@ -54,6 +55,19 @@ If you want the plugin to be enabled on startup use the `g:auto_save` option.
let g:auto_save = 1 " enable AutoSave on Vim startup
<

--------------------------------------------------------------------------------
ENABLE FOR BUFFER *auto-save-enable_for_buffer*

If you want the plugin to be enabled for a specific buffer use the `b:auto_save` option.
>
" .vimrc
augroup todo
autocmd!
" enable AutoSave for todo buffers
autocmd filetype todo let b:auto_save = 1
augroup END
<

--------------------------------------------------------------------------------
SILENT *auto-save-silent*

Expand All @@ -79,31 +93,30 @@ the default, will save on every change in normal mode and every time you leave i
let g:auto_save_events = ["InsertLeave", "TextChanged"]
<

Using `CursorHold` will additionally 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. See the autocommands overview for a complete listing
().
Other events you may want to use:

Be advised to be careful with the `updatetime` option since it has shown to
* `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 ().

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.
>
" .vimrc
set updatetime=200 " Dangerous!
let g:auto_save_events = ["CursorHold", "CursorHoldI", "CompleteDone", "InsertLeave"]
<

--------------------------------------------------------------------------------
POSTSAVE HOOK *auto-save-postsave_hook*
(PRE/POST)SAVE HOOKS *auto-save-(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 before each save
" 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()
Expand Down