Visual Studios Syntax Highlighting

I noticed in the matrix multiplication example in the CUDA Programming Guide that the syntax was highlighted a la visual studios. I’m using visual studios, but the .cu files have no highlighting. Is there some easy way to get this working? Also - there’s no chance that whatever Microsoft’s auto-complete is called is supported for CUDA code, is there?


User keywords can be highlighted in Visual Studio by (creating and) editing a file named “usertype.dat” in the directory %vs_install_dir%\Common7\IDE. There are example keyword files in the CUDA SDK package (%NVSDKCUDA_ROOT%\doc\syntax_highlighting) that you can copy to VS dir and modify to suit your needs. The user keywords can be configured to have the colour of the VS keywords (default) or a common colour of their own.

I think I got Intellisense (auto-complete) to work under certain circumstances by adding *.cu files to the list of “C/C++ File Extensions” under Options -> Projects and Solutions -> VC++ Project Settings, but I’m not sure if that was the only (and effective) option to enable auto-complete on my IDE.


Thanks! I didn’t realize they included the usertype.dat file. However, intellisense doesn’t seem to be working as usual. While I can now highlight and then right click a symbol and the usual stuff such as go to definition is now available, I never get auto-complete boxes popping up. Also, any function that is defined with a CUDA keyword, such as global, can’t be found when I right click a highlighted symbol. I understand it’s trying to interpret the function as a C++ function, and global is not a C++ term, hence it doesn’t bother including it in the intellisense database… Is there no better solution? I know NVIDIA has an investment in Microsoft Visual Studios, perhaps they have an absolutely no warranties, may cause instant user death, double alpha version of some plugins?

Has anyone solved a solution for intellisense? Auto-complete would be very handy when developing cuda applications.

yes, auto-complete will be very handy while code edit. I am looking for such a way to realize it. what I used ever in VS2005 is Visual AssistX, and it works fine for .cpp or .c files, but cut no ice in .cu file. So is there any one can realize it? expecting for the answer.

We can use the tool Visual Assist X to implement it:

First, find the Visual Assist X install directory:

\Program Files\Visual Assist X\Autotext, then make a copy of Cpp.tpl, rename it to Cu.tpl, apply same operation to the “Latest” directory.

Second, open the regedit table, and search it with the key word “Visual Assist X” until you find in the VANet8 in HKEY_USERS\S-1-5-21-1757981266-220523388-725345543-1003\Software\Whole Tomato\Visual Assist X\VANet8

Here you can see many attribute setting about Visual Assist X,

click the item ExtHeader and add the .cu in the list, same to the item ExtSource.

save and quit.

Is it possible to train Visual Assist X somehow?
It only recognizes variable types that I have already implemented in my code but not all of CUDAs variable types.

would be cool if you could “feed” Visual Assist X with all of CUDAs variable types, functions etc.

Any ideas?

yes, it would be great and I have tried adding all the highlight key words in visual assist X by edit the .tpl file. now, all the key words in usertype.dat can be autotext. if you want to realize function autotext, all you need to do is edit the .tpl file following its format.

nice hint hakuna, works perfectly!
makes coding CUDA a lot faster.

Thanks man!

I can’t get it to work.

I’ve downloaded Visual Assist X from and installed it. Then copied the ‘Cpp.tpl’ and renamed it to ‘Cu.tpl’ (only one instance in ‘C:\Program Files\Visual Assist X\AutoText\Latest’).

Then found the VANet8 folder in regedit and added “.cu” to the list in ExtSource and ‘.cuh’ in ExtHeader.

Restarted Visual Studio and openned my CUDA project (with a ‘.cu’ file in it) and there’s no intellisense there (I can’t see the function overloads using Ctl+Shift+Space or any variable types using mouse-over).

Can anyone suggest why it’s not working?

Or is it working and does Visual Assist do something different to normal Intellisense?

(I can see the extra context menu items for ‘VA X’… is that all it’s supposed to do… or does it ‘fix’ intellisense for CUDA source code?)

Could you share your Cu.tpl file? I don’t know what to add and how.

I also meet the same problem with you. Hope it is helpful for you:

Before performing the steps taught by hakuna, please remember to close all VS2005/VA. If a VA is running, I think it will restore the registry items when it exit so that your modification became useless.

Just modify the registry when no VS / VA running. It worked in my case.

Getting back to syntax highlighting, does the usertype.dat solution work OK for you? Keywords are recognised but I get no syntax highlighting for comments

Did you add interpretation of .cu files as c/c++ under Tools->Options->Text editor->File extensions? My .cu file comments are as green as the comments in my other .cpp files (I suppose this is what you want?).

Oh, my bad. I accidentally assigned .cu files to MS Visual Basic editing experience. It’s working fine now.

i cant see ExtHeader or ExtSource item in VAANet8 folder.

(although be maked VANet8 folder in regedit, after Visual Studio start up)

so i create pairs:ExtHeader-.cuh & . but intellisense dont move.

plz give me any comment

compiler:visual studio2005

visual assist x 10.4 trial

i have found ExtHeader and ExtSource items in VANet8, today…

probably they are made recently…


FYI, I think a better method is in the Visual Assist X settings dialog, under “Projects->C/C++ Directories”. Switch from “win32” to “Custom”, and add “C:\CUDA\include”. Then restart your IDE. Once VA X parses that directory, all the CUDA built-ins and intrinsics (functions and keywords) will be available for intellisense (assuming you’ve set up the registry and VS settings already).

This should also answer the question about “training” VA X.

Great post worked like a charm (both 2005 2008 and 2010 are now coloring and completing)

As a side note I’ll just say I learned how to edit the tpl files which is recommended if you’re bored or else consider yourself part of a programming elite or something like that.

Follow these steps:

Add cu and cuh extensions to NCB Default C/C++ Extensions key under
HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0\Languages\Language Services\C/C++ path

if never modified you can also run the reg file attached: [attachment=17628:cuIntellisense.reg.txt] (remember to change file extension)