Wednesday, August 29, 2012

Re: Autocmds

On Wednesday, August 29, 2012 5:36:53 PM UTC-5, Jan wrote:
> On Wednesday, 29 August, 2012 at 15:28:47 BST, Ben Fritz wrote:
>
> >> But FileType autocmds get executed at every display of the buffer, not just when loading the file.
>
> >
>
> >This didn't sound right, but I did an experiment, and by default it is quite true. In my setup, actually, it is also true.
>
> >
>
> >But if you set the 'hidden' option, it is no longer true. FileType only fires when actually reading the file with 'hidden' set, for me at least.
>
>
>
> Aha, I didn't think about hidden! Good catch. I see the same behaviour when I set it, too, which solves my problem -- thanks!
>
>
>
> >I don't have 'hidden' set because I am forgetful and don't like risking that I might do a bunch of work, go to compile, and realize I forgot to save a header file or something.
>
>
>
> Is there something about setting hidden that stops vim warning when you try to exit without "!" (eg. :qa)?
>

Nope, but I tend to leave Vim running after editing so that doesn't help me too much. If I did quick edits in Vim and then quit Vim before compiling that could solve my problem. Or doing :wa right before. But sometimes I have stuff I'm not ready to save yet.

Come to think of it, I have stuff I don't want to save infrequently enough that doing :wa might be a good idea anyway.

Related options (can be used together with or independently from 'hidden' depending on what you want Vim to do when you close a file or quit) are 'confirm' and 'autowriteall'. I personally set 'confirm' and neither of the others.

--
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

No comments: