Sharing Code Snippets

What are Code Snippets? Internal Link

Code snippets are small pieces of code, hence "snippets" of code, that can be shared while commenting.

Code Snippet Example

With FastComments, simply pasting a snippet of code should automatically be detected and formatted.

When commenting, the code snippet will be wrapped in <code> blocks, and the formatting happens after you submit your comment.

The wrapping in <code> blocks is automatic when pasting a snippet of code, in many languages.

Alternatively, you can highlight a piece of text and click the Code button in the toolbar.

Coding Communities Internal Link

Code Snippet Sharing is useful for communities where sharing code is likely to happen.

This makes shared pieces of code easier to read with little effort from your users.

We hope that this feature makes FastComments an ideal choice for programming related sites and applications.

Programming Languages Supported Internal Link

When sharing code snippets, FastComments does its best to automatically determine which programming language the code snippet is in to automatically format and apply syntax highlighting.

FastComments syntax highlighting currently supports 39 common languages:

  • .properties
  • Apache
  • config
  • Bash
  • C
  • C#
  • C++
  • CSS
  • CoffeeScript
  • Diff
  • Go
  • HTTP
  • JSON
  • Java
  • JavaScript
  • Kotlin
  • Less
  • Lua
  • Makefile
  • Markdown
  • Nginx
  • config
  • Objective-C
  • PHP
  • PHP Template
  • Perl
  • Plain text
  • Python
  • Python REPL
  • R
  • Ruby
  • Rust
  • SCSS
  • SQL
  • Shell
  • Session
  • Swift
  • TOML and INI
  • TypeScript
  • Visual Basic .NET
  • YAML

When sharing a code snippet in a language we don't support, it will still be rendered like code - but no syntax highlighting or reformatting will be applied.

Setting Up Code Snippet Sharing Internal Link

No setup is required to enable this feature. It is automatically available to your users when using FastComments.

Sharing Code Snippets Internal Link

To use Code Snippet support, simply paste any bit of code that is indented by two or four spaces, and includes the { or ( characters.

Alternatively, paste your code snippet, highlight it, and click the Code option in the toolbar