LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 09-05-2021, 07:47 PM   #1
Tem2
Member
 
Registered: Dec 2011
Posts: 243

Rep: Reputation: Disabled
Gedit is not remembering last cursor position


In my previous installation, gedit defaulted to open my files at the last cursor position. I just re-installed ubuntu 20.04 and gedit opens my files at the top of the document.

I found a thread which explains how to disable the feature with the following steps:

Code:
gconf-editor
apps
gedit-2
preferences
editor
cursor_position
restore_cursor_position = No
So I thought I could change the restore_cursor_position to Yes to solve my problem.

Unfortunately, when I install the gconf-editor, there is no gedit-2 option in the apps section.

I've tried other editors, but they do the same thing.

How do I get gedit to open my files at the last cursor position by default?

Or, is there another editor which will do this?
 
Old 09-06-2021, 01:34 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,850

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
https://askubuntu.com/questions/1724...e-gconf-editor
probably it is renamed, it is gconftool-2

From the other hand I think every editor can do that, including vi and emacs.
 
Old 09-06-2021, 02:11 AM   #3
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,670

Rep: Reputation: Disabled
gedit migrated from GConf to dconf/GSettings in 2010 (as part of transition from GNOME 2 to GNOME 3). Use dconf-editor resp. gsettings instead. The setting is there:
Code:
$ gsettings describe org.gnome.gedit.preferences.editor restore-cursor-position
Whether gedit should restore the previous cursor position when a file is loaded.

Last edited by shruggy; 09-06-2021 at 02:49 AM.
 
Old 09-06-2021, 02:46 AM   #4
Tem2
Member
 
Registered: Dec 2011
Posts: 243

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by shruggy View Post
Use dconf-editor resp. gsettings instead. The setting is there:
Code:
$ gsettings describe org.gnome.gedit.preferences.editor restore-cursor-position
Whether gedit should restore the previous cursor position when a file is loaded.
This looks promising. I'm running xfce so I think I should be using the dconf-editor and not the gconf-editor. I really am lost when it comes to this level of understanding linux.

I've been trying to figure out how to set that key (restore-cursor-position) to true. Or even how to display the current value of the key. I'm not even sure if it is a key. I'm a little lost.

I've been trying to decipher the man page for gsettings, but it just confuses me more.

I apologize for my ignorance, but this is how we learn things, right?

So my question is, what is the gsettings command to set restore-cursor-position to true.

Thanks!
 
Old 09-06-2021, 02:52 AM   #5
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,670

Rep: Reputation: Disabled
Quote:
Originally Posted by Tem2 View Post
what is the gsettings command to set restore-cursor-position to true.
Code:
gsettings set org.gnome.gedit.preferences.editor restore-cursor-position true
or just
Code:
gsettings reset org.gnome.gedit.preferences.editor restore-cursor-position
(it should be true by default).
 
Old 09-06-2021, 03:28 AM   #6
Tem2
Member
 
Registered: Dec 2011
Posts: 243

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by shruggy View Post
Code:
gsettings set org.gnome.gedit.preferences.editor restore-cursor-position true
or just
Code:
gsettings reset org.gnome.gedit.preferences.editor restore-cursor-position
(it should be true by default).
I executed both of these commands and gedit still opens at the top of the file after I make changes in the middle of the file.
 
Old 09-06-2021, 03:35 AM   #7
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,670

Rep: Reputation: Disabled
Are you sure it's gedit you're using and not, say mousepad (which is part of default Xubuntu installation)?
 
Old 09-06-2021, 04:11 AM   #8
Tem2
Member
 
Registered: Dec 2011
Posts: 243

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by shruggy View Post
Are you sure it's gedit you're using and not, say mousepad (which is part of default Xubuntu installation)?
I have a launcher on my panel that is set to open a specific file with gedit.

When I saw your post, I tried opening the file from the command line. I made some changes and went back in to the file the same way and it remembered the cursor position.

It turns out that my launcher was configured using sudo gedit and that is what was causing the problem. I have no idea why I would have done that to open a specific file which did not require super user privileges.

Problem solved.

But now that you know the root cause of this problem, do you know why opening gedit as a super user behaves differently?

Thanks for all your help!
 
Old 09-06-2021, 04:17 AM   #9
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,670

Rep: Reputation: Disabled
gsettings changes settings for the current user, not for root.
 
1 members found this post helpful.
Old 09-13-2021, 12:48 AM   #10
Tem2
Member
 
Registered: Dec 2011
Posts: 243

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by shruggy View Post
gsettings changes settings for the current user, not for root.
I'm very sorry to have to report that the problem has resurfaced and this time I'm not opening gedit with the sudo command. Everything was working really well, and then, poof. It wasn't working well anymore. gedit is not remembering my last cursor position in changed files even when I open without the sudo command.

I was really happy for a minute. And now I'm back to relative sadness.

Please help me.
 
Old 09-13-2021, 01:04 AM   #11
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,850

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
I guess you open files with gedit with and without su (or sudo). And [I guess] now the gedit config file is read only for the user and you even cannot configure it (because it is write protected and owned by root).
The only solution to this problem is to avoid doing it. (or actually you may try to make a workaround, but that looks extremely difficult to me).
 
Old 09-13-2021, 01:35 AM   #12
Tem2
Member
 
Registered: Dec 2011
Posts: 243

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
I guess you open files with gedit with and without su (or sudo). And [I guess] now the gedit config file is read only for the user and you even cannot configure it (because it is write protected and owned by root).
The only solution to this problem is to avoid doing it. (or actually you may try to make a workaround, but that looks extremely difficult to me).
Sometimes I need to edit a file with sudo because it is a system file. I admit that when it comes to permissions on files I really don't have a clue.

Is there a way to restore the gedit config file to default settings? I uninstalled gedit and reinstalled it and it didn't make any difference. I also tried:

Code:
gsettings set org.gnome.gedit.preferences.editor restore-cursor-position true
and that didn't work either.
 
Old 09-13-2021, 01:51 AM   #13
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,850

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
better to use a different editor for system files (for example nano).
 
1 members found this post helpful.
Old 09-13-2021, 01:53 AM   #14
Tem2
Member
 
Registered: Dec 2011
Posts: 243

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
better to use a different editor for system files (for example nano).
I was thinking the same thing. But first I have to get gedit back to its default settings. Any thoughts?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] emacs how to go back to last cursor position while browsing code skaushal_lk Programming 9 06-13-2013 10:01 AM
[SOLVED] Gedit cursor saves position Mr. Alex Linux - Software 1 08-30-2010 10:29 AM
Remember last cursor position in VIM rangalo Debian 4 05-12-2007 09:52 AM
vim: startup at last cursor position chrism01 Solaris / OpenSolaris 3 02-20-2007 11:25 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 09:31 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration