Syntax highlighting for hosts files

File under: sublimeextensionhosts.

Syntax highlighting for your hosts file

See this page on

Syntax highlighting for your hosts file; /etc/hosts on Linux and macOS, C:\Windows\System32\Drivers\etc\hosts (?) on Windows.

This is a complete rewrite of an older Hosts package that provided more or less the same thing, except of course for some improvements:

  • It only highlights IP addresses that are actually viable. For example: it won’t match the impossible movie IP-address (Bytes cannot have values higher than 255…) This makes it easier to spot errors.
  • It makes IP addresses in three private ranges stand out by giving them a different colour. It supports all three private ranges:,, and
  • Loopback addresses ( and ::1) get a distinguishable colour too. (Thanks to Michael B. Lyons).
  • It indexes the hosts so you can use Goto Symbol to quickly go there. (Made by Michael Blyons)
  • IPv6

Credit where credit’s due:

David M. Syzdek wrote the regular expressions for matching IP-addresses that I adapted for this plugin.

The mysterious Michael B. Lyons provided several pull requests with a range of features and fixes. In fact, he added so much that you can consider it to be a complete rewrite of the code we started with.