After adding the tags, a similar question appeared in the Related tab (same problem, different cause, and user Renan suggested in the comments to run gedit from the terminal and look for error messages.
This was the output:
** GtkSourceView:ERROR:gtksourcecontextengine.c:5421:update_syntax: assertion failed: (state->context != NULL) Aborted (core dumped)
This is caused by a bug in gedit that gets triggered when setting the language to Defaults. Since this selection gets saved in the GnomeVFS, even copying the file in Nautilus doesn't help, since it preserves the metadata.
To solve this problem, as indicated in the bug report, I executed the following command:
gvfs-set-attribute FILENAME metadata::gedit-language ''
Solved.