text color of file.cuf

Dear all,

I just started learning cuda fortran. I used to write my codes in f90 extension. Now when I write in cuf extension, all the text is in black. How do I turn the color mode on so different syntax have different colors?



Hi Lam,

I can think of 2 options:

  1. This is an editor independent option. Use .f90 (or equivalent) extensions instead of .cuf (to get the syntax highlighting you want) and add -Mcuda to the compile line (to get the compiler to recognize that the file has CUDA FORTRAN code in it).

  2. This is an editor dependent option. Use .cuf extensions and let your editor know that .cuf should have FORTRAN syntax highlighting. For Vim you can open the file and do :set syntax=fortran. This is a temporary solution and would need to be done each time the file is opened (tedious some). A more permanent solution in to add the line let filetype_cuf = “fortran” to ~/.vimrc . If you use an editor other than Vim, a quick Google should help you find the equivalent concept.


Thanks Kyle,

For the permanent solution I had to create a .vimrc as it did not exist. I put in the file the following:

syntax on
filetype on
au BufNewFile,BufRead *.cuf set filetype=fortran



I’m a bit late to this, but I have some syntax files for CUDA Fortran if you’d like them. They are essentially a superset of the bits in the current fortran.vim from vim.

It highlights all the CUDA additional commands to make CUDA Fortran a bit more colorful.