Julia syntax highlighting in julia

I use gvim with julia-vim for editing julia code. I am using julia 0.5 on a mac and installed julia-vim with vundle.

My problem is that files with the .jl extension do not have appropriate highlighting. For example, if is highlighted but for is not. Any solution for this?


.jl files are sometimes recognized as lisp files by default, (blame Sawfish) so that's probably the syntax highlighting you're getting. (type defun and progn and etc and see if the pretty colors pop up)

You were close when you said the correct solution was :set syntax=julia , what you need is to set filetype plus some autocmd magicks to make that happen every time you open a .jl file.

Put something like this in some file (eg jl.vim ) in your ftdetect directory:

autocmd BufRead,BufNewFile *.jl :set filetype=julia

And that should do it.



Addendum 1 : Changing filetype instead of syntax may be required to trigger additional features like the LaTeX expansions depending on the root of your problem, so that's what I am using.


Addendum 2 : Note that this should've been handled by the julia-vim plugin, but conflicts with other scripts can mess with that. You can use :scriptnames to see what scripts have been loaded and in what order, and try to debug what could be causing the conflict, if you think that's worth the trouble.


Addendum 3 : Also related is that Vundle has some specific configurations that need to be made when it comes to filetypes, so that could also be causing this. However, I've seen this and similar problems happen outside Vundle for any number of reasons so I still believe that the solution at the top is the best one, and will possibly prevent some future headaches.


After testing julia-vim I think the issue is likely with the color scheme you are using.

Try using a different one.

:colorscheme desert

I tried it with the built-in desert and both if and for were highlighted (see below).

在这里输入图像描述

链接地址: http://www.djcxy.com/p/95618.html

上一篇: 如何在iOS上的Safari中滚动时监视滚动位置?

下一篇: 朱莉娅在朱莉娅的语法高亮