When I edit a .cu
file in Microsoft Visual Studio 2010, the editor treats it as a regular text file (there are no colors on keywords such as int
, float
etc. Closing brackets are not highlighted).
How do I enable syntax highlighting of .cu
files in Visual Studio, so that editing .cu
files is like editing regular C / C++ files?
Adding '.cu' under c++ extension in visual studio settings would enable syntax highlighting for c++ keywords only. EDIT: It in Tools -> Options -> Text Editor -> File Extension
type in cu and select Microsoft Visual C++ as the editor and click add
To add CUDA keyword syntax highlighting you can search for usertype.dat
in your CUDA installation folders (make sure if it is not found in the Program Files folder to search for it in your home folder -> AppData-> Local -> NVIDIA Corporation
(sorry that I'm not providing the details since I don't have Windows right now), then copy it to Program Files\Microsoft Visual Studio 10.0\Common7\IDE
and restart Visual Studio
But, But! still it might not work, so what you are ended up with AFAIK you can use Visual Assistant x and then you have to change it's settings as follows:
For VS2010, VS2008, VS2005 and VS.NET:
Add your extension to:
Tools | Options | Projects | VC++ Build | C/C++ File Extensions (VS.NET)
Tools | Options | Projects and Solutions | VC++ Project Settings | C/C++ File Extensions (VS2005, VS2008)
Tools | Options | Projects and Solutions | VC++ Project Settings | Extensions To Include (VS2010)
Exit the IDE and use regedit to clone the following entry to a like entry that ends in your extension:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0\Languages\File Extensions\.cpp
If you are using a 64bit OS then clone the registry key:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\8.0\Languages\File Extensions\.cpp
If your extension denotes a header, use regedit
to add the extension to ExtHeader
in the following location. Remember to include the dot and terminating semicolon:
HKEY_CURRENT_USER\Software\Whole Tomato\Visual Assist X\VANet8
If your extension denotes a source file that is not a header, add the extension to ExtSource
in the following location.
HKEY_CURRENT_USER\Software\Whole Tomato\Visual Assist X\VANet8
Press Rebuild on the Performance tab of the Visual Assist X options dialog and restart your IDE.
Replace 8.0
with 10.0
if you use VS 2010.
Replace 8.0
with 9.0
if you use VS 2008.
Replace 8.0
with 7.1
if you use VS.NET 2003.
Replace 8.0
with 7.0
if you use VS.NET 2002.
Replace VANet8
with VANet10
for Visual Studio 2010.
Replace VANet8
with VSNet9
if you use VS2008.
Replace VANet8
with VSNet
if you use VS.NET 2003.
Replace VANet8
with VANet7
.0 if you use VS.NET 2002.
For VC++ 6.0:
Exit your IDE and use regedit
to add the extension to:
HKEY_CURRENT_USER\Software\Microsoft\DevStudio\6.0\Text Editor\Tabs/Language Settings\C/C++\FileExtensions
.
If your extension denotes a header, use regedit
to add the extension to ExtHeader
in the following location. Remember to include the dot and terminating semicolon:
HKEY_CURRENT_USER\Software\Whole Tomato\Visual Assist X\VA6
If your extension denotes a source file that is not a header, add the extension to ExtSource
in the following location.Remember to include the dot and terminating semicolon:
HKEY_CURRENT_USER\Software\Whole Tomato\Visual Assist X\VA6
Press Rebuild on the Performance tab of the Visual Assist X options dialog and restart your IDE.
In addition to what someone else has already said (adding cu extension in Tools -> Options -> Text Editor -> File Extension and Microsoft Visual C++ as editor), I also recommend you, in order to avoid the highlighting of CUDA keywords (like threadIdx.x etc), to include:
#include<device_launch_parameters.h>
Right click your project, select Build Customizations, then select one of the CUDA build customization files. If there are no CUDA build customization files available, you must first install Nsight Visual Studio Edition or a CUDA distribution in which it is bundled.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With