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.
2 Answers
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 ''
BOM was the culprit in my case. In order to remove it from PHP file run the following:
sed '1s/^\xEF\xBB\xBF//' < ~/Desktop/params.php > ~/Desktop/params2.php
In order to overwrite original file use another command:
sed -i '1s/^\xEF\xBB\xBF//' ~/Desktop/params.php
If BOM is in a source file it will be removed, if not, then file will remain unchanged.
The answer is taken from here.
-
Same here. It seems to depend on the file extension as well; it's fine with a UTF-8 BOM in a file named
*.txt
, but in a*.pl
or*.php
file it makes it blow up. (I assume this is related to the syntax highlighting somehow.)– ruakhApr 6, 2019 at 2:21
gedit ~/Desktop/params.php
... output:** GtkSourceView:ERROR:gtksourcecontextengine.c:5545:update_syntax: assertion failed: (g_slist_length (ce->priv->invalid) <= 1) Aborted (core dumped)