jeff_h
jeff_h

Reputation: 539

spf13 - using the java syntax in a file with a non java extension

So this may be a trivial issue to resolve.

The company I work for has their own file format, and it contains java like code.

Right now there is no syntax highlighting when I open their files with vim, after installing spf13.

Is there somewhere I can add their file extension to, in order to get have syntax highlighting?

essentially I need spf13 to recognise the file extension as java.

Thanks!

Ps I did cp the file and replace their extension with .java and the syntax highlighting worked fine :)

Upvotes: 0

Views: 72

Answers (2)

Ingo Karkat
Ingo Karkat

Reputation: 172580

Your filetype isn't recognized by Vim. To teach Vim to highlight them as java, create a file ~/.vim/ftdetect/MYEXT.vim and insert the following command:

autocmd BufRead,BufNewFile *.MYEXT setfiletype java

For more information, see :help new-filetype, especially :help ftdetect.


This is how it works in plain Vim. Vim "distributions" like spf-13 and Janus lure you with a quick install and out-of-the-box settings, but you pay the price with increased complexity (you need to understand both Vim's runtime loading scheme and the arbitrary conventions of the distribution) and inflexibility (the distribution may make some things easier, but other things very difficult). Vim is incredibly customizable, using someone else's customization makes no sense. If you struggle to implement this within spf-13, read its documentation carefully, ask on their issue tracker, and seriously consider moving away from it.

Upvotes: 1

Adam Katz
Adam Katz

Reputation: 16138

Put this in your ~/.vimrc or ~/vim/filetype.vim:

augroup filetypedetect
  au BufRead,BufNewFile *.jeff_h setfiletype java
augroup END

You didn't denote what the extension was, so I specified it above as .jeff_h

Upvotes: 1

Related Questions