If you want vim to be able to syntax highlight and indent scala source files you can
First of all go here and you will see three sub-directories: ftdetect
, indent
and syntax
.
Each one of the sub-directories contains a file called scala.vim
. Download them. Notice that if you save them one after the other they will overwrite one another, so you might want to give them names like scala-ftd.vim
, scala-ind.vim
and scala-syn.vim
.
If you only want your user to have scala filetype support, you can move the files into ~/.vim. Make sure the directories ~/.vim/ftdetect
, ~/.vim/indent
and ~/.vim/syntax
all exist then:
mv scala-ftd.vim ~/.vim/ftdetect/scala.vim
mv scala-ind.vim ~/.vim/indent/scala.vim
mv scala-syn.vim ~/.vim/syntax/scala.vim
This is a good solution if you don’t have root access on the system. If you do and you want all your users to have access to scala filetype detection, do the following instead:
mv scala-ftd.vim /usr/share/vim/addons/ftdetect/scala.vim
mv scala-ind.vim /usr/share/vim/addons/indent/scala.vim
mv scala-syn.vim /usr/share/vim/addons/syntax/scala.vim
What if it doesn’t work?
I grabbed my scala vim files from a different location and they refused to work. Looking at :set
output in vim I saw that there was garbage at the end of the filetype name (scala^M instead of scala). If this happens to you you can solve it by converting line-endings from DOS to UNIX. There are about 100,000,000 ways to do this, including writing your own little script in **your favorite language**, but the simplest possible solution might be this:
% su
[enter root password]
# aptitutde install tofrodos
# exit
% cd ~/.vim/ftdetect/scala.vim
% fromdos scala.vim
Make sure you invoke fromdos
on the other two scala.vim files as well. Once that is done, scala filetype support should work.