Wednesday, August 22, 2012

Re: Autocmds

On 2012-08-22, Paul wrote:
> I have a Perl script, filename 'thescript'. Vim correctly
> identifies it as a Perl script when I open it. I have various
> autocmds set up for when I open .pl files, which naturally don't
> execute on thescript.
>
> I can :doautocmd whenever I want to execute relevant autocmds, but
> that doesn't mean that thescript has those autocmds associated
> with it. Is there a way I can tell vim to pretend that thescript
> is called thescript.pl, and therefore have those autocmds
> associated with it (without renaming the file)? Or is there some
> way of defining autocmds to work on filetype as well as or instead
> of filename pattern?

You can use FileType autocommands in your ~/.vimrc like this,

au FileType perl setlocal tw=2

or you can put all the commands (not as autocommands) in a file
named ~/.vim/after/ftplugin/perl.vim. See

:help FileType
:help filetype-plugin
:help ftplugin-overrule

Regards,
Gary

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