1

So I decided to to go through Damian Conway's (a well known Perl programmer) .vimrc setup as a way to get more familiar with vim and how it works. His first line is this:

autocmd BufNewFile,BufRead *.t setfiletype perl

But there is no line like this in the file:

autocmd BufNewFile,BufRead *.pl setfiletype perl

the .vimrc file also does not have a :filetype on command.

I'm curious to know: is there is some other method to get vim to automatically recognize what kind of file is getting worked on? Thanks.

3

Vim recognises common file extensions by default, that's why you don't need to take care of .*pl.

The relevant code is in filetype.vim in Vim's program folder – go take a look.

Interestingly, the code for .pl is slightly more complicated than your line as it distinguishes between Prolog and Perl.

  • Yeah, what was confusing me is I did not have filetype detection turned on and so the file was not getting recognized as *.pl. I learned that once I turned that on and reloaded the file, the file was then automatically recognized as a perl file. Thanks. – StevieD Feb 11 '17 at 23:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.