Ubuntu – gedit flashes and exit automatically when opening a file

geditUbuntu

Environment:Ubuntu 11.10 gedit 3.2.3
When I open a specific .php file with gedit, it will appear in a flash and disappear immediately. I searched the web and found one way to get around this – use gconf to change the encoding of gedit but I didn't find the key it mentioned. I tried to use VIM to change the encoding of this .php file to UTF-8 and that didn't work either.

Best Answer

I had a similar problem (caused by a different bug), but the underlying causes might be similar enough for this to work:

gedit saves metadata about all known files using the GnomeVFS. If that metadata contains something gedit doesn't "like", it crashes.

As a workaround, create a copy of the file from the command line (not in Nautilus). cp doesn't preserve the metadata, so this allow you to open the file if the metadata is in fact the problem.

In case it is, you can inspect the file's metadata by executing the following command:

gvfs-info -a metadata FILENAME

Then, one by one, try erasing the entries using the following syntax:

gvfs-set-attribute FILENAME metadata::ATTRIBUTE ''
Related Question