Monday, August 27, 2012

Re: Autocmds

On Monday, August 27, 2012 2:04:24 PM UTC-5, Jan wrote:
> On Thursday, 23 August, 2012 at 16:01:30 BST, Ben Fritz wrote:
>
> >Switch to checking filetype instead of file extension, something like:
>
> >
>
> >au BufWritePost * if &ft=='perl' | make | endif
>
>
>
> When I try this:
>
>
>
> autocmd BufRead * if &ft == 'perl' | setlocal makeprg=perl\ -cw\ % | endif
>
>
>
> makeprg doesn't get set, I guess because vim sets the filetype to "perl" only after BufRead has happened (the :help doesn't say). The :help does hint at using BufWinEnter instead, which works for this case, but it seems suboptimal having these autocmd commands executed every time I display the buffer, when really I only need them executed the once, after buffer read/load.
>

The event you want for the loading of the file is FileType. As mentioned before.

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