Posting Code with Syntax Highlighting

Hope this is helpful!

When adding code to posts, you can post your code so that it’s formatted with syntax highlighting. This will help to make the code easier to read and hopefully easier for others to troubleshoot.

You use fenced code blocks to automatically get syntax highlighting. The following format is the basic idea:

```cpp
{your code}
```

Need a real example?

If you paste the following into a post:

```cpp
#include "robot-config.h"
vex::competition    Competition;

// Main will set up the competition functions and callbacks.
int main() {                    
    while(1) {
        vex::task::sleep(100);
    }    
}
```

Will be automatically formatted like the following:

#include "robot-config.h"
vex::competition    Competition;

// Main will set up the competition functions and callbacks.
int main() {                    
	while(1) {
		vex::task::sleep(100);
	}    
}

More Details

For extra documentation, you can read the following pages that describe fenced code blocks in detail:

5 Likes