On Tuesday, October 15, 2013 12:12:49 PM UTC-4, Gary Johnson wrote:
> On 2013-10-15, FlashBurn wrote:
>
> > I need to execute a function on certain file types (say c and
>
> > make) when they are saved. I understand that autocmd is involved
>
> > somehow but I can't figure it out.
>
> >
>
> > I need something like this
>
> >
>
> > autocmd BufWritePreFileType c,make :call MyFunction()
>
> >
>
> > Any help is appreciated.
>
>
>
> There are two ways I can think of off-hand to do that. One is this:
>
>
>
> au BufWritePre * if &ft == "c" || &ft == "make" | call MyFunction() | endif
>
>
>
> which you can put in your ~/.vimrc. The other is this:
>
>
>
> au BufWritePre <buffer> call MyFunction()
>
>
>
> which you would put in the files (on Unix)
>
> ~/.vim/after/ftplugin/c.vim and ~/.vim/after/ftplugin/make.vim.
>
>
>
> Regards,
>
> Gary
Thanks Gary. I think I will use a first approach.
--
--
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.
For more options, visit https://groups.google.com/groups/opt_out.
Tuesday, October 15, 2013
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment