📅 2015-Mar-26 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ cuda, syntax highlighting, vim ⬩ 📚 Archive
Vim has had syntax highlighting support for CUDA source files for a long time now. You can check this: open any
.cu file and try the command
:set filetype?. You will see that Vim knows that it is a CUDA source file. It applies the syntax highlighting from the file
So, what is the problem? The syntax highlighting done by Vim for CUDA is very very minimal. My CUDA source files look like pages of plain white text in Vim! Also, the comments in the
cuda.vim file that it was last updated in 2007. Now that is old!
There is an alternate
cuda.vim syntax file for Vim floating around on the web. You can get it, for example, from here.
I replaced the
cuda.vim that ships with Vim with this one and found it slightly better. But not by much. It still looks like lots of plain text.
The better solution for me was to just syntax highlight CUDA file as C++ file. This gave the best results, with the highest number of elements in the file being colored when compared to above two methods.
To do this, add this line to your
autocmd BufRead,BufNewFile *.cu set filetype=cpp
Tried with: Vim 7.4 and Ubuntu 14.04