How to write underscore "_" in comments?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By lukas
:warning: Old Version Published before Godot 3 was released.

Many GDScript funstions have 2 underscores inside and thus instead of underscore sign “_” we see text in italics.

:bust_in_silhouette: Reply From: lukas

Solution is to write backslash "" before the underscore: “\_”.

:bust_in_silhouette: Reply From: Bojidar Marinov

Use the grave accent character to surround code. It would look like this:

Using `_fixed_process` we can...

Using _fixed_process we can…

:bust_in_silhouette: Reply From: Akien

Actually for GDScript code you should always use backquotes as mentioned by bojidar_bg, or use a complete code block formatting (by prefixing everything with four spaces, or selecting your copy-pasted code and clicking the “code” button). For example:

func \_input\_event():
    # this is a properly formatted code chunk
    # and underscore\_are\_not\_parsed\_as\_italic\_markers</code>

Which gives:

func _input_event():
    # this is a properly formatted code chunk
    # and underscore_are_not_parsed_as_italic_markers

But for normal text that contains underscores (e.g. URLs), it can indeed be a bother that it gets processed as Markdown italics, so you need to escape the underscore as mentioned by lukas (e.g.: some\_text\_with\_underscores), or format it as code as suggested by bojidar_bg (e.g.: `some_text_with_underscores`).