907th / vim-auto-save Goto Github PK
View Code? Open in Web Editor NEWA Vim plugin which saves files to disk automatically.
License: MIT License
A Vim plugin which saves files to disk automatically.
License: MIT License
I know this is kinda small, but I was wondering if there is a way for vim-auto-save to tell you what time it auto-saved in AM/PM time.
so that one can discover variables via :h vim-auto-save
I'm using gvim on Windows. I used Vundle to install the plugin from here. When this plugin is loaded, if I try to enter ^X mode
by pressing CTRL-X in INSERT
mode, it immediately exits back into the general INSERT
mode. If I comment out the line Plugin 'vim-scripts/vim-auto-save'
and change it to " Plugin 'vim-scripts/vim-auto-save'
then I can enter and stay in ^X mode
. I'm not completely familiar with VimL for plugins otherwise I would try toggling some of the g:
variables. Could you tell me if there is any fix for this?
Hello,
Thank you for this supplement to Vim which I use every day !
Recently, to try to improve keyboard typing comfort, I left the "insert" mode by "Ctrl + c" instead of "escape" touch.
In this case, it seems that auto-save does not work. Is there a way around the problem?
Thank you in advance for your answer.
Is it possible to enable autosave on a per buffer basis ?
I like to enable it for python but would prefer not saving buffers with other ft.
Thanks for the plugin.
I don't see a reason why somebody ever should want to loose his '[
']
marks.
Since it is our plugin that removes the marks it should also always restore it. I think it is redundant to have that as a configurable option.
If i use https://github.com/terryma/vim-multiple-cursors your plugin saved after each changes, but not end multiply editing. How can I fix it?
Firstly thanks for the plugin 👍🏽
It would be nice to add installation directions for users who don't have vundle
.
Plus it would be nice for new users to configure the setup easily, not everyone used vundle, plug etc
For e.g for neovim users :
mkdir -p ~/.config/nvim/pack/vim-auto-save/start && cd $_
vim-auto-save
git clone https://github.com/907th/vim-auto-save.git
init.vim
file if needed and it is done!Let me know if this is what you want, I will send a PR
How i can configure vim-auto-save, to save only under git repositories. Now are saving all my files.
I've set the autosave to get fired when switching window, however if i happened to have an opened fuzzy finder i.e. non-writable listing buffer, then the following error message would pop up.
Error detected while processing function terminus#private#term_focus_lost[2]..FocusLost Autocommands for "*"..function AutoSave[26]..DoSave:
Line 4:
E565: Not allowed to change text or change window: buffer 106
I know that it's just an edge case, but improvements are always welcome (Unless it'd compromise something else).
Hello, I use InsertLeave
to trigger the autosave function. However, the cursor always stuck when I leave insert mode.
Since vim 8 and neovim use job_start()
and jobstart()
to run command in asynchronous way, so I'm wondering is there any way in asynchronous can help for this problem?
When I add this plugin to my vim.
vim blocked.
After I delete it, vim works again.
Is there any setting that allows me to make it so vim-auto-save only starts autosaves after the file is written (manually using :w
)?
I want this kind of setting because when I enter a new file using vim, I don't want vim-auto-save to immediately save after opening, because I might want to not keep the new file.
My current settings for vim-auto-save is only let g:auto_save = 1
Software:
Ubuntu, wsl2
nvim
I added TextChangedI
as an event. vim-auto-save
abruptly shifts cursor position to the left while inserting text. Guess it is a escape
and entering insert mode with i
issue.
If you have auto save enabled, .
no longer works when doing a surround command. For example, if you do a cs'"
to change single quotes to double quotes, then hit .
to repeat it elsewhere, it does not work. Disabling autosave works.
Since I have enabled this pluggin in vim 8.0 just looking at some files causes timestamps to be updated. This means various compilation occur needlessly for me. There should be a check that the file has actually changed when saving. I have setup the plugin with CursorHold & CursorHoldI, I don't know if that matters.
Thank you.
I don't know very well the vim language. It looks like it it does check if file was modified but calls save regardless
https://github.com/907th/vim-auto-save/blob/master/plugin/AutoSave.vim#L74
perhaps that line should be in the if block checking if it was modified.
this vim plugin works so cool,it auto saves changes on the fly,but some times it's not the action we want,for example: misstroke the keyboard carelessly would also auto save the error changese which we do not want when in insert mode,and if add the auto_save_interval options it would mitigate it's influnce.
First off - this is a great plugin and always ensures all my buffers are in sync with the disk.
However with go files (I use fatih/vim-go plugin), whenever I do any change, the auto-save plugin saves my work and the go plugins run a sanity check and linting.
Post that, I am not able to perform any undo action.
Undo is working absolutely fine in all other files, just not with go files.
Here is my vimrc
packadd! matchit
set ruler
filetype plugin indent on
filetype plugin on
set nocompatible
set history=100
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
endif
set autowrite
set tabstop=4
set softtabstop=4
set expandtab
set showcmd
filetype indent on
set wildmenu
set showmatch
set undofile
set undodir=/Users/akshay/.vim/undo
if empty(glob('/Users/akshay/.vim/autoload/plug.vim'))
silent !curl -fLo /Users/akshay/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
call plug#begin('~/.vim/plugged')
Plug 'junegunn/vim-plug'
Plug 'dkarter/bullets.vim'
Plug 'fatih/vim-go'
Plug 'tpope/vim-fugitive'
Plug '907th/vim-auto-save'
Plug 'vim-airline/vim-airline'
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'ctrlpvim/ctrlp.vim'
call plug#end()
let mapleader=","
nnoremap :nohlsearch
map :cnext
map :cprevious
map :GoDecls
map :GoDeclsDir
nnoremap a :cclose
nnoremap al :GoAlternate
nnoremap e :GoTest
nnoremap f :GoTestFunc
nnoremap gs :Gstatus
nnoremap sr :source~/.vimrc
nnoremap t
autocmd vimenter * NERDTree
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | exe 'cd '.argv()[0] | endif
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
function! s:build_go_files()
let l:file = expand('%')
if l:file =# '^\f+_test.go$'# '^\f+.go$'
call go#test#Test(0, 1)
elseif l:file =
call go#cmd#Build(0)
endif
endfunction
autocmd FileType go nmap b :call build_go_files()
autocmd FileType go nmap c (go-coverage-toggle)
autocmd FileType go nmap r (go-run)
autocmd FileType go nmap e (go-test)
let g:go_def_mode='gopls'
let g:go_info_mode='gopls'
let g:auto_save=1
let g:auto_save_no_updatetime = 1
let g:auto_save_write_all_buffers=1
let g:go_fmt_command = "goimports"
let g:go_auto_type_info = 1
let g:go_auto_sameids = 1
let g:go_list_type = "quickfix"
`
Sample go file
package main
import (
"os"
"text/template"
)
type Test struct {
Name string
}
func main() {
tmp := template.New("SMS").Option("missingkey=zero").Delims("${", "}")
tmp, _ = tmp.Parse("${.otp} is your OTP for ${.company} Freight")
par := make(map[string]string)
par["otp"] = "1234"
tmp.Execute(os.Stdout, par)
}
With let g:auto_save_events = ['CompleteDone']
my cursor jumps to the begining of the paragraph / block when I press Shift :
. The strange thing is that it happens only when inserting a breakline in the first line and then typing some text ending by ":" (see attached gif for example)... I'm not really sure what to make of that...
Hi! It'd be great to have an option to enable throttling when having this config
let g:auto_save_events = ["InsertLeave", "TextChanged"]
Context: I use a file watcher tool, and if too many changes are made in a short interval, sometimes it doesn't catch the latest change. If vim-auto-save
could batch changes every 500ms, that'd be perfect.
Thank you so much for this awesome piece of software. I couldn't picture myself coding without it.
Hi.
Thanks for plugin.
I need behaviour like vscode or phpstorm, when save works, when window lose focus.
How can i implement this?
You should probably add an option to prevent vim-auto-save from changing the updatetime setting since it's global and affects other plugins as well.
When using Syntastic, normally any configured Syntastic checks are run automatically on saving a file.
With vim-auto-save enabled, however, the Syntastic checks don't seem to fire. Only when using :w
to manually save a file with vim-auto-save enabled, or when manually executing :SyntasticCheck
do we get a syntax check.
I know the plugin is based on the Rubymine behavior which saves automatically every 200ms.
But vim feels different then Rubymine.
A switch to insert mode is atomic for me. I change something and am back in normal mode as soon as possible. So a save during that time is unnecessary and even disadvantages for me, because it disrupts my writing and splits my changes into multiple which are then not represented in my undo/repeat list as they would be in vim without vim-auto-save.
200 ms update time in normal mode often causes problems for me with other plugins and syntax highlighting. So I increase it or switch it off completely. But at the same time I want to be sure, that as soon as I use the file (read it with another program, execute it) the file is in the most recent state. So I add the auto save event TextChanged which operates in normal mode and saves on every text change.
I would like to know how other people are using vim-auto-save. And whether it would make sense to adjust the default options based on that, to have an installation which works for as many people out of the box as possible.
Noupdatetime is set. This happens with coc-snippets.
For example: in command line show message (Automatically saved)
.
When I have vim-auto-save enabled, I cannot use this helpful trick to select recently pasted text http://vim.wikia.com/wiki/Selecting_your_pasted_text
When you use
`[v`]
, it selects the entire file.
This duplicate entry is added after an InsertLeave and after the user moves the cursor.
Enter insert-mode.
Type anything.
Exit insert mode.
Move the cursor using any motion.
Here is an example below. I am using undotree to visualize the undo history.
I am using Neovim latest version (version 0.3.2). It seems that I can not see the autosave hint on the status bar right now. My settings for autosave:
let g:autosave = 1
let g:auto_save_events = ["InsertLeave", "TextChanged"]
let g:auto_save_silent = 0
If I leave the insert mode, how much time will it take for autosave to work? Or, will it work immediately after I exit insert mode?
Edit: It seems that the above setting is not enough. I have manually use :AutoSaveToggle
command to activate autosave. Any idea what is wrong?
A minimal .vimrc
such as this
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin '907th/vim-auto-save'
call vundle#end()
will cause <C-x> <C-f>
to fail.
I'd be willing to at least help facilitate contributions to this under the auspices of Preservim, a GitHub org I started back in 2016 or so to help revive some unmaintained but still useful plugins. It started with nerdcommenter,but has grown to cover quite a few from there. We have attracted a handful of maintainers that have pitched in to keep old plugins afloat.
The modus operendi would be to have you join the org, transfer the repo there, stick around as the repo owner, but start a team with maintainer level privileges on the repo and approach anybody who looked like a regular contributor with sound ideas to join. We usually add some basic CI checks to make sure the plugin loads and runs as expected and them limit merges to 1 approving reviewer.
I've been a user of this plugin for many years. I can't promise to do a tone of work on it, but it probably doesn't need a whole lot either. I can help facilitate any PRs or issue triage that people do jump in with and at least get CI stuff running.
If you're interested let me know.
Like some log file, I may edit it accidentally, so I don't wanna save it automatically, also git commit, I might wanna drop it instead of saving it.
Hey, thanks for nice plugin!
I have autocmd
command for auto sourcing my vimrc. And when the plugin is saving file I'm getting my vim unnecessary frozen during sourcing the config..
autocmd bufwritepost $MYVIMRC source $MYVIMRC
It would be nice to have a setting to ignore/exclude some files, smth like this:
let g:auto_save_files_ignore = [$MYVIMRC]
Btw I have these settings:
let g:auto_save = 1
" https://github.com/907th/vim-auto-save/issues/53#issuecomment-571819789
let g:auto_save_events = ["CursorHold"]
set updatetime=300
Btw2 I can donate few dollars for this feature!
With this plugin installed if you simply open vim and type, auto-save will attempt to save the buffer even though attempting this will result in an error, and in my case a prompt to continue. It'd be nice if there was an option to disable attempted saves to files with no name.
Error detected while processing CursorHold Auto commands for "*":
E32: No file name
Press ENTER or type command to continue
First-off: Great plugin! Auto-saving is a revelation.
I've run into a minor annoyance: Let's say I record a macro with qqAhello<Esc>q
. Then, I run the macro 22 times with 22@q
.
Normally (with auto-save disabled), running the macro 22 times as I did is counted as one change. So I can undo all of it with a single u
.
With auto-save enabled, each of the 22 runs is counted as a separate change. I would have to press u
22 times or 22u
to get back to where I was.
Not sure what the best way to deal with this is or if it should even be dealt with. Just want to bring it to your attention.
Saving on any change in insert mode can be quite a lot and it leads to some integrations/plugins flickering. Wouldn't it make more sense to only auto save once I'm back in normal mode? Could this be a configurable option or even the default? Usually, in Vim, going into insert mode, changing multiple things and then going back into normal mode only counts as one change so I would also expect this plugin to only save after I've gone back into normal mode.
Any feedback?
receiving this error:
zsh 1796 [1] % vi .vim/bundle/vim-auto-save/plugin/AutoSave.vim
Error detected while processing /Users/toddbush/.vim/bundle/vim-auto-save/plugin/AutoSave.vim:
line 46:
E216: No such group or event: TextChanged * nested call AutoSave()
Press ENTER or type command to continue
vim version:
zsh 1796 [1] % vi --version
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Jun 14 2016 16:06:49)
Compiled by [email protected]
Normal version without GUI. Features included (+) or not (-):
-arabic +autocmd -balloon_eval -browse +builtin_terms +byte_offset +cindent
-clientserver -clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments
-conceal +cryptv +cscope +cursorbind +cursorshape +dialog_con +diff +digraphs
-dnd -ebcdic -emacs_tags +eval +ex_extra +extra_search -farsi +file_in_path
+find_in_path +float +folding -footer +fork() -gettext -hangul_input +iconv
+insert_expand +jumplist -keymap -langmap +libcall +linebreak +lispindent
+listcmds +localmap -lua +menu +mksession +modify_fname +mouse -mouseshape
-mouse_dec -mouse_gpm -mouse_jsbterm -mouse_netterm -mouse_sysmouse
+mouse_xterm +multi_byte +multi_lang -mzscheme +netbeans_intg -osfiletype
+path_extra -perl +persistent_undo +postscript +printer -profile +python/dyn
-python3 +quickfix +reltime -rightleft +ruby/dyn +scrollbind +signs
+smartindent -sniff +startuptime +statusline -sun_workshop +syntax +tag_binary
+tag_old_static -tag_any_white -tcl +terminfo +termresponse +textobjects +title
-toolbar +user_commands +vertsplit +virtualedit +visual +visualextra +viminfo
+vreplace +wildignore +wildmenu +windows +writebackup -X11 -xfontset -xim -xsmp
-xterm_clipboard -xterm_save
system vimrc file: "$VIM/vimrc"
user vimrc file: "$HOME/.vimrc"
user exrc file: "$HOME/.exrc"
fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -D_FORTIFY_SOURCE=0 -Iproto -DHAVE_CONFIG_H -arch i386 -arch x86_64 -g -Os -pipe
Linking: gcc -arch i386 -arch x86_64 -o vim -lncurses
I'm using NeoVim 0.2 on macOS 10.12.5.
When Using the plugin with default options, I can no longer undo changes made in normal mode (maybe also other changes, but didn't test specifically). When I set leg g:auto_save_events = ["InsertLeave"]
it seems to work as expected again.
Is this a known problem or bug? Or can I tweak this with config settings?
For things that are watched by fs watchers an autosave while typing is a little brutal and can cause them to miss changes. I wonder if CursorHoldI could be optional.
Hi,
I can't seem to make it toggle for ruby files only.
I tried:
augroup auto_save_for_ruby
autocmd!
autocmd Filetype *.rb :AutoSaveToggle()
augroup END
Any suggestion on how to make this happen?
—Alberto
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.