Tag Archive for 'colour'

Adding CUDA synatx to Nano - Part 2

Just to complete all colourings for CUDA files, I added the missing __*__-specifiers. Builtin types like uint4 will be now coloured too. The magic variables blockIdx, threadIdx, … and the function syncthreads() will all be handled as something specific but I think the most are only interested in the nanorc-file for colouring CUDA code in GNU Nano.

Adding CUDA synatx to Nano - Part 1

Since GNU Nano is my favorite editor on the commandline and I am developing things with CUDA at the moment, I wanted to have the comfort of coloured code code. Since CUDA is just C/C++ with some minimal synatx additions, I modifed the C-syntax file which is loacted in /usr/share/nano/c.nanorc in my system.

First we need to tell nano to colour .cu-files too, not only .c, .cpp and … This is done through adding a u| in front of pp|xx in the line starting with syntax, normally line 3. After that the line should look as following:

syntax “c” “\.(c(c|u|pp|xx)?|C)$” “\.(h(h|pp|xx)?|H)$” “\.ii?$”

For the beginning I included the colouring of the __*__-specifiers and the <<<…>>> blocks. I hope this block is self-expalining (if there are some problems look at `man nanorc`), you could add this to the end of the file:

## CUDA Syntax
color cyan “\<(__shared__|__global__|__device__|__host__)\>”
color red,yellow start=”<<<” end=”>>>”

Of course you need not to use the colours I’ve choosen, feel free to choose your favourite ones, all available colours are listed in `man nanorc`.