It’s really awkward if the CUDA file displayed as a normal file in Visual Studio. It’s essentially following C style format. But the keywords are different from C/C++. But Visual Studio is flexible enough to give editor experience for a custom file.
So what you’ve to do to enable syntax highlighting for CUDA Source files? It’s clearly described in the CUDA SDK help files.
1. Setup CUDA in your box. (Install the CUDA SDK and CUDA Toolkit)
2. Browse to “Microsoft Visual Studio 8\Common7\IDE” folder from your program files folder
3. Open the user “usertype.dat” file from the folder. If the file doesn’t exists, create a new one in the name.
4. Open the %Program Files%\NVIDIA Corporation\NVIDIA CUDA SDK\doc\syntax_highlighting\visual_studio_8
5. Append the content of “usertype.dat” to the previously opened “usertype.dat” file from “Microsoft Visual Studio 8\Common7\IDE”
6. Save the file
7. Open You IDE and Take Tools -> Options.
8. Under Text Editor -> File Extension tab, specify the extension “cu” as a new type (as pictured below)
1. Restart your IDE
2. Enjoy Syntax highlighting
Note that the above settings are applicable for Visual Studio 8 only. For Visual Studio 7 the setup is slightly different. You can see the instruction from NVIDIA Corporation\NVIDIA CUDA SDK\doc\syntax_highlighting\visual_studio_7 folder once you install the CUDA SDK.

12 Comments
It was very helpful.
Thanks
Note that this enables syntax highlighting (which is really nice), but it doesn’t enable IntelliSense for .cu files.
That’s correct Fooble. But do you know how to enable IntelliSense so it can support Cuda functions, variables, etc??
Just to let you know, this also works on Visual Studio 2008 which is supported from CUDA 2.1 beta onwards.
It doesn’t Quite work for VS2008 -
All the c highlighting works fine – from the .cu file association However CUDA keywords are still not highlighted…
__global__
__host__
__device__
__constant__
__shared__
HOW DO Keyword highlight in visual c++ 6.0????
BACKGROUND TEXT
OR
SET COLOR(X,Y)
visual c++ 6.0
visual c++ 6.0
visual c++ 6.0
visual c++ 6.0
PLEAS HELP ME
INTERMANCH@GMAIL.COM
Thank you! Really useful! It works for Visual Studio 2005!
Syntax Highlighting worked for the VS 2008 as well.
Thank you!
Thank you for the post.
Worked pretty fine.
Thanks very much
Thanks! This is really great!
Thank you so much!
This really helped me out…
2 Trackbacks
[...] But in Windows world, most of the developers are much satisfied with the IDE Visual Studio. So may have to leave the world of command line compilation and source editing in favor of improving our productivity. If we can integrate the CUDA development to Visual Studio IDE, that’s pretty nice no? In one of my previous post, I said about enabling syntax highlighting for CUDA files under Visual Studio. [...]
[...] Enable CUDA Syntax Highlighting from MS Visual C++ [...]