Monday, October 24, 2022

Re: How to autosave files when terminal is closed

SigUSR1 didn't work. I wonder why SigTERM isn't in autocmd-events.

That plugin is a bit overkill (vim already stores unsaved changes in
swap files), and hooks into events like CursorHold (cursor inactivity)
and CompleteDone.

Why isn't this possible in VimLeavePre (if not VimLeave)? :|

On Mon, 24 Oct 2022 09:16:55 +0000, Owajigbanam Ogbuluijah wrote:
> Hi Dennis,
>
> Are you asking for an event which fires when you close the terminal
> within Vim — opened with *:term* — *or* the terminal window that's
> housing Vim?
>
> If it's the later, I wonder if SigUSR1 may help here? — where SigUSR1
> is the interrupt your terminal sends to Vim in the event that it's
> being closed impromptu — *disclaimer: I haven't tried this; I'm just
> inferring from the docs* — *:h autocmd-events*
>
> If you want to autosave, there's a nifty battle-tested Vim plugin —
> vim-auto-save <https://github.com/vim-scripts/vim-auto-save> — which
> I've entrusted to doing this for me.
>
>
> Best,
> Igbanam.
>
> On Mon, Oct 24, 2022 at 6:42 AM Dennis Nezic
> <dennisn@dennisn.mooo.com> wrote:
>
> > "au VimLeavePre * w" only works when I exit vim with something like
> > ":q!" but not if I close my terminal window.
> >
> > Error detected while processing VimLeavePre Autocommands for "*":
> > E749: Empty buffer
> >
> > VimLeave[Pre] is being called, but the buffer is not saved, probably
> > because it's closed before that event is triggered. Is there another
> > event that gets triggered during the closing sequence that will
> > allow me to autosave, or another way to do this?
> >
> > --
> > --
> > You received this message from the "vim_use" maillist.
> > Do not top-post! Type your reply below the text you are replying to.
> > For more information, visit http://www.vim.org/maillist.php
> >
> > ---
> > You received this message because you are subscribed to the Google
> > Groups "vim_use" group.
> > To unsubscribe from this group and stop receiving emails from it,
> > send an email to vim_use+unsubscribe@googlegroups.com.
> > To view this discussion on the web visit
> > https://groups.google.com/d/msgid/vim_use/20221023224251.eaf04689726b89d749e73d9b%40dennisn.mooo.com
> > .
> >
>
> --
> --
> You received this message from the "vim_use" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
> ---
> You received this message because you are subscribed to the Google
> Groups "vim_use" group. To unsubscribe from this group and stop
> receiving emails from it, send an email to
> vim_use+unsubscribe@googlegroups.com. To view this discussion on the
> web visit
> https://groups.google.com/d/msgid/vim_use/CAOmRJreOa6xqQ6%3D%2BU8zX7D3N7DpXfrJ4nPVaoP3yGzjNMoLaUQ%40mail.gmail.com.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20221024093653.1b9ffc61469df49044f71997%40dennisn.mooo.com.

No comments: