How to Enable Syntax Highlighting for CUDA files in Visual Studio 2005?

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.

image

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)

image

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.

Sharing my thoughts...

This entry was posted in Uncategorized. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

12 Comments

  1. RockSamurai
    Posted October 31, 2008 at 10:55 pm | Permalink

    It was very helpful.
    Thanks

  2. Fooble
    Posted January 9, 2009 at 11:22 pm | Permalink

    Note that this enables syntax highlighting (which is really nice), but it doesn’t enable IntelliSense for .cu files.

  3. Nevaco
    Posted January 16, 2009 at 8:52 am | Permalink

    That’s correct Fooble. But do you know how to enable IntelliSense so it can support Cuda functions, variables, etc??

  4. cr333
    Posted January 20, 2009 at 1:55 pm | Permalink

    Just to let you know, this also works on Visual Studio 2008 which is supported from CUDA 2.1 beta onwards.

  5. MechLab
    Posted February 1, 2009 at 2:11 pm | Permalink

    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__

  6. Posted February 7, 2009 at 7:24 pm | Permalink

    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

  7. ipapag
    Posted February 12, 2009 at 5:58 pm | Permalink

    Thank you! Really useful! It works for Visual Studio 2005!

  8. Anderson
    Posted May 25, 2009 at 1:48 am | Permalink

    Syntax Highlighting worked for the VS 2008 as well.

    Thank you!

  9. Bruno
    Posted June 8, 2009 at 8:09 am | Permalink

    Thank you for the post.
    Worked pretty fine.

  10. steven
    Posted June 18, 2009 at 7:29 pm | Permalink

    Thanks very much :)

  11. ___Harry___
    Posted August 10, 2009 at 5:24 pm | Permalink

    Thanks! This is really great!

  12. Jahanzeb
    Posted January 2, 2010 at 11:31 am | Permalink

    Thank you so much!

    This really helped me out…

2 Trackbacks

  1. [...] 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. [...]

  2. [...] Enable CUDA Syntax Highlighting from MS Visual C++ [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>