I found that my ~/.vimrc
file has syntax on
but it didn't work for any CUDA file (.cu
).
Not sure to how to do it.
I found that my ~/.vimrc
file has syntax on
but it didn't work for any CUDA file (.cu
).
Not sure to how to do it.
Add these two lines to ~/.vimrc:
au BufNewFile,BufRead *.cu set ft=cuda
au BufNewFile,BufRead *.cuh set ft=cuda
And put cuda.vim in ~/.vim/syntax/
Have fun!
Sounds like you might be missing the syntax highlighting file for vim. You should check your /usr/share/vim/vim70/syntax
directory for cuda.vim
. That directory will vary depending on your system and version of vim.
If your version of vim does not come with cuda.vim
, you can download this cuda.vim file and place it in ~/.vim/syntax/.
Update: add the following lines in your ~/.vimrc
as @BenjiWiebe recommended:
au BufNewFile,BufRead *.cu set filetype=cuda
au BufNewFile,BufRead *.cuh set filetype=cuda
how about that, does this work ?
cd /usr/share/vim/vim*/syntax
sudo cp cpp.vim cu.vim
echo "au BufNewFile,BufRead *.cu set ft=cu" >> ~/.vimrc
It's been long since the question was originally asked, but I found myself having almost the same issue and not being able to solve it by following the previous answers.
In my case, vim would automatically highlight .cu files (I'm using vim 80, which already has cuda.vim in /usr/share/vim/vim80/syntax/), but ignore .cuh ones. To solve this, I edited /usr/share/vim/vim80/filetype.vim and added
au BufNewFile,BufRead *.cuh setf cuda
And that was it!