Search code examples
vimviml

Match partial filetype in vimscript


I have a file that's being recognized as jasmine.coffee in VIM, but &filetype=='coffee' evaluates to false.

Is there a way to do a partial filetype match in Vimscript


Solution

  • Use the =~ pattern matching operator instead, which will treat the right side as a regular expression to test against.

    &filetype =~ 'coffee' 
    

    This is mentioned in the Conditionals section of the Vimscript documentation.