2

I am new to vim and was wondering if there is a way for files that have already been manually saved to be automatically saved (every few seconds). I currently make a lot of new files (for testing plugins, etc.) that I don't want to keep, and so I want this function to only apply to files I have already manually saved at least once. Thank you!

1 Answer 1

1
  1. Every time you save, you add buffer number to a global set, it can be done with autocmd with BufWritePost event or custom save command.
  2. Write a function to go through all the buffers that have been saved, save it again if &modified is true.
  3. Add an autocmd with CursorHold event and your function.
2
  • Instead of a save command, why not autocmd for BufWritePost ?
    – D. Ben Knoble
    Commented Mar 28, 2019 at 1:11
  • Good point :) .
    – dedowsdi
    Commented Mar 28, 2019 at 1:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.