1

I have html settings set up in my ~/.vim/ftplugin/html.vim file. I would like these settings to apply to Rhtml files as well. I made a symbolic link with

ln -s ~/.vim/ftplugin/html.vim ~/.vim/ftplugin/Rhtml.vim

Why doesn't this load my html settings when I open a .Rhtml file?

  • 2
    I don't know why a symlink doesn't work, but the usual approach for this is to create a rhtml.vim file which uses runtime! ftplugin/html.vim. Here's an example. – Martin Tournoij Sep 19 '17 at 15:33
  • @Carpetsmoker I like the runtime! ftplugin/html.vim idea, but I can't get that to work either. I copied your example to ftplugin/rhtml.vim but it doesn't work. When I open a .Rhtml file, the default vim settings apply. When I try set ft=html, the html settings load. What could I be doing wrong? – ichbinallen Sep 19 '17 at 15:54
  • 1
    Are you sure that the filetype is set correct? What does verbose set filetype? say? – Martin Tournoij Sep 19 '17 at 15:56
  • You mean enter :verbose set filetype as a command from within vim? I get filetype=. This means there is no filetype set for my .Rhtml file, right? – ichbinallen Sep 19 '17 at 16:02
  • Yeah, I meant as a command. How are you setting the filetype? Is it possible you forgot to add a ftdetect script? (like this one?) – Martin Tournoij Sep 19 '17 at 16:04
4

The symlink you've created at ~/.vim/ftplugin/Rhtml.vim tells Vim how to handle files with the RHTML filetype, but you haven't told Vim how to recognise which files should have this filetype.

Instructions for how to do so can be found in the documentation by running the command :help new-filetype.

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.