Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6916215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:34:24+00:00 2026-05-27T09:34:24+00:00

I frequently develop on Ruby on Rails. With the recent inclusion of Tilt in

  • 0

I frequently develop on Ruby on Rails. With the recent inclusion of Tilt in RoR 3, we have file extensions like .scss.erb. How can I make the filetype = scss.erb in this case automatically, and the same for every file that has multiple extensions?

Edit: It should be scss.eruby in this case, as erb extension defaults to eruby filetype.

Edit: If it wasn’t clear, I’m looking for a way to make this work dynamically for all files with multiple extensions. For example, file foo.js.html should have a filetype of js.html.

Edit again: Prince Goulash’s answer doesn’t take the default filetype for a particular extension.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T09:34:24+00:00Added an answer on May 27, 2026 at 9:34 am

    In your vimrc:

    autocmd BufRead,BufNewFile *.scss.erb setlocal filetype=scss.eruby
    

    (see :help ftdetect, section 2).

    EDIT

    To set the filetype dyanamically for multiple extensions, this seems to work for me:

    autocmd BufRead,BufNewFile *.*.*
        \ sil exe "setlocal filetype=" . substitute(expand("%"),"^[^.]*\.","",1)
    

    The substitute command constructs the filtype by simply stripping all text from the filename before the first .. There may be a more sophisticated way…

    EDIT AGAIN

    Here’s another attempt. MultiExtensionFiletype() is function that uses the default filetype of the last part of the extension and prefixes it with the first part of the extension (i.e. the part sandwiched between the dots).

    function MultiExtensionFiletype()
        let ft_default=&filetype
        let ft_prefix=substitute(matchstr(expand('%'),'\..\+\.'),'\.','','g')
        sil exe "set filetype=" . ft_prefix  . "." . ft_default
    endfunction
    

    The function must be called on a BufReadPost event so the initial filetype is set by ignoring the multiple extensions.

    autocmd BufReadPost *.*.* call MultiExtensionFiletype()
    

    Hopefully this answer is converging on something useful!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have to develop an application like Google Draw, not exactly the same. The
I frequently find myself wanting to change something like this, in a layout file:
Frequently I'll have a workflow like the following: Commit changes to a group of
I frequently deal with UTF-16LE files encoded on windows which have a \r\n carriage
I frequently have some code that should be run either on a schedule or
I frequently have svn-based projects that include third-party components such as the TinyMCE (in-browser
I frequently need to ssh into a server, but I can't ssh into it
I frequently find myself writing utility classes that can be re-used throughout my projects.
Frequently I am aligning text such as: To: 07/02/2010 From: 07/02/2010 Id like it
Frequently I have run into a problem when installing gems that provides a problem

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.