There are two things you can try. First, try opening the file with sudo
in the first place. To do this, you'll need to place a symlink to the subl
shortcut in /usr/bin
:
sudo ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/bin/subl
Then, you can just run
sudo subl /etc/hosts
enter your password, and continue as normally.
Second, I'd highly recommend setting
"atomic_save": false
in your user preferences (Sublime Text -> Preferences -> Settings-User
). The error you are getting is on a temp file created by atomic saving, and as I explain in the linked answer above, file metadata can get altered or lost when using this "feature", so it's best to just turn it off.