VScode: Disable syntax highlighting for a range of lines

336 views Asked by At

I'm using SDCC's inline assembly syntax for my project:


void delay_ms(uint16_t ms) {
    _ms = ms;
    __asm
        ldw y, __ms         ; Load ms counter into y register: 2 cycles
    0000$:
        ldw x, _CYCLES_PER_MS   ; Load tick counter into x register: 2 cycles
    0001$:              
        decw x          ; Decrease tick counter: 1 cycle 
        jrne 0001$      ; Check if 1ms passed: 2 cycles (except for x == 0 where it's just 1 cycle)
                
        decw y          ; Decrease ms counter: 1 cycle
        jrne 0000$      ; Check if provided time has passed: 2 cycles (except for y == 0 where it's just 1 cycle)
    __endasm;
}

Unfortunately VScode's language syntax highlighting still interprets the inline assembly code as C code which is quite annoying:

enter image description here

Is it possible to completely disable syntax highlighting for a range of lines in your file?

1

There are 1 answers

0
Dorin Botan On

There is no default setting for that, and as far as I can see, no extension that supports it.

It is possible to treat the entire file as an asm source file. This will still support some very basic C highlighting. To do this, look for asm-collection mode in Select Language Mode menu.

enter image description here

enter image description here

Alternatively, highlighting can be disabled entirely for the file, via the same menu, or, through settings.json in case it needs to be applied to multiple files.

"files.associations": {
    "*.c": "plaintext",
},