Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Start C++ syntax highlighting for .cu (CUDA) files

Tags:

emacs

I use Emacs as an editor. Of late whenever I use CUDA files (which usually have extensions .cu) I have to manually do M-x c++-mode to turn on syntax highlighting and other yasnippet features.

How do I do I ensure that all .cu files when started in EMACS automatically borrow all the C++ mode features. In other words .cu extension becomes an alias for .cpp extension.

( I know there is a CUDA mode for EMACS, (not inbuilt) but when I installed this mode it does not turn on many of the useful features present in the C++-mode of emacs )

like image 575
smilingbuddha Avatar asked Dec 26 '11 00:12

smilingbuddha


2 Answers

Putting this into your .emacs should do the trick:

(add-to-list 'auto-mode-alist '("\\.cu\\'" . c++-mode))
like image 101
Rörd Avatar answered Sep 17 '22 06:09

Rörd


Just in case people have missed it; there's a slightly more official cuda-mode available: http://www.emacswiki.org/emacs/CudaMode

You need to put it somewhere in your load-path; for example on my Mac, I put the code in $HOME/Library/emacs/cuda-mode.el and added the following lines to my .emacs file.

(add-to-list 'load-path "~/Library/emacs")
(autoload 'cuda-mode "cuda-mode.el")
(add-to-list 'auto-mode-alist '("\\.cu\\'" . cuda-mode))
like image 38
Sam Mason Avatar answered Sep 20 '22 06:09

Sam Mason