Many text editors store your last cursor position in files you have edited. The information is often only stored for files you have saved with the editor, and different editors may behave differently in this regard. But it is not stored in the file you edited. It is stored somewhere else instead, because inside a plain text file, there is no good place to put it. Gedit uses gvfs to store and retrieve this information for each file.
As explained in CrazyApe84's own answer to Where does gedit store the last cursor position? (on Ask Ubuntu), gedit remembers where you were in each file by writing your cursor positions to ~/.local/share/gvfs-metadata/home
. It reads them back when you reopen the file. Rather than containing explicit code to open, write, and read that file, gedit uses gvfs and that file is where these particular gvfs data happen to be stored. The information is stored in the metadata::gedit-position
gvfs attribute of each file you edit. The reason that is not a contradiction is that a file's gvfs attributes aren't part of the file or even its regular filesystem metadata. They are stored in files the gvfs-metadata
directory, like home
.
If you want to view--or even edit--this information yourself, install the gvfs-bin
package:
sudo apt update
sudo apt install gvfs-bin
(That's for Debian and its derivatives, such as Ubuntu, which you are using. Also, depending what desktop environment you are using, commands like gvfs-info
may be installed already. But gedit does not use these command-line utilities itself and installing gedit
on a non-GNOME desktop environment does not install gvfs-bin
.)
Then you can use the gvfs-info
command to view the attribute. Suppose the file you edited was called your-file
and it is in the current directory. Then run:
gvfs-info -a metadata::gedit-position your-file
Or, as CrazyApe84's answer explains, you could grep for metadata::gedit-position
(or just position
, if you're willing to have a few extra lines) in the output of gvfs-info your-file
:
gvfs-info your-file | grep metadata::gedit-position
There is a popular fork of gedit called pluma, which comes with the MATE desktop environment (and which, like gedit, can be installed separately if you use a different desktop environment). If you're using pluma instead of gedit, the attribute is metadata::pluma-position
rather than metadata::gedit-position
. In case you've ever wondered why gedit and pluma don't share information about where you were in a file, that's why.
~/.config
for this as you suggest, gedit doesn't store last cursor position information there. Instead, it uses gvfs attributes. – Eliah Kagan Oct 23 '17 at 12:48