05 December 2012

VIM Syntax Highlighting for Scala: A Bash One-Liner

Just for posterity, here is a Bash one-liner to download the VIM plugins to handle syntax highlighting for Scala:

mkdir -p ~/.vim/{ftdetect,indent,syntax} && for d in ftdetect indent syntax ; do wget --no-check-certificate -O ~/.vim/$d/scala.vim https://raw.githubusercontent.com/derekwyatt/vim-scala/master/syntax/scala.vim; done
Update

Here is a solution using cURL submitted by Joe:
mkdir -p ~/.vim/{ftdetect,indent,syntax} && for d in ftdetect indent syntax ; do curl -o ~/.vim/$d/scala.vim https://raw.githubusercontent.com/derekwyatt/vim-scala/master/syntax/scala.vim; done

34 comments:

  1. Thanks bro, works saved me some work!

    ReplyDelete
  2. Substituting cURL:

    mkdir -p ~/.vim/{ftdetect,indent,syntax} && for d in ftdetect indent syntax ; do curl -o ~/.vim/$d/scala.vim https://raw.github.com/scala/scala-dist/master/tool-support/src/vim/$d/scala.vim; done

    ReplyDelete
  3. I can use the 5 minutes I gained getting Scala syntax highlighting from this post to tell you how much I like it :). But seriously, thanks! I know I'll use it again on some other machine ... somewhere.

    ReplyDelete
  4. Nice work Bruce. (hope all is well)

    ReplyDelete
  5. Thanks, that saved me a lot of time! I had to change the url to `https://raw.githubusercontent.com` to actually be able to download the files (I'm guessing that Github changed it recently, in which case you might want to update it in your post as well)

    ReplyDelete
  6. Thank you for this great solution!

    ReplyDelete
  7. This comment has been removed by the author.

    ReplyDelete
  8. updated url:

    mkdir -p ~/.vim/{ftdetect,indent,syntax} && for d in ftdetect indent syntax ; do curl -o ~/.vim/$d/scala.vim https://raw.githubusercontent.com/scala/scala-dist/master/tool-support/src/vim/$d/scala.vim; done

    ReplyDelete
  9. This is a quick way, but Vundle or Pathogen would be a better approach.

    If you are interested I recently wrote an article about programming Scala in Vim - http://lauris.github.io/vim/2014/08/21/scala-in-vim/

    ReplyDelete
  10. I used the above bash command on my MacBook pro terminal and it executed successfully. After that, $vi test.scala and types a few scala statements but I do not see the syntax highlighted. Am I missing something?

    ReplyDelete
    Replies
    1. Do you have syntax highlighting enabled in Vim? Did you manually check for the correct directories and files after running the command? (~/.vim/ftdetect/ ~/.vim/indent and ~/.vim/syntax)

      Delete
  11. Thanks Bruce. I did check for these directories. But it works now.

    ReplyDelete
  12. It no longer works. Here is an update:

    mkdir -p ~/.vim/{ftdetect,indent,syntax} && for d in ftdetect indent syntax ; do wget --no-check-certificate -O ~/.vim/$d/scala.vim https://raw.githubusercontent.com/derekwyatt/vim-scala/master/syntax/scala.vim; done

    ReplyDelete
  13. Saved me some time, thanks!

    ReplyDelete
  14. the kudos keep coming! Thanks for putting this together, Bruce, and for keeping it updated, Arun. cheers!

    ReplyDelete
  15. Thanks man! helped me a lot :)

    ReplyDelete
  16. Awesome script. I will not have to go out of my terminal now.

    ReplyDelete