Ubuntu – Swift syntax highlighting in gedit

geditsyntax highlighting

I do not see an option for Swift highlighting in the gedit language menu. How can I get gedit to highlight Swift code for me?

Best Answer

A language definition for Swift has recently been added to the git repository of GtkSourceView (the library that performs syntax highlighting in gedit). It hasn't made it into any GtkSourceView release yet, but you can download it here:

https://git.gnome.org/browse/gtksourceview/plain/data/language-specs/swift.lang

Place this file (swift.lang) in this directory, creating it if necessary:

~/.local/share/gtksourceview-3.0/language-specs/

Then gedit will highlight Swift code for you.