+215

Retain cursor position on file change

Jake Archibald 13 years ago updated by Steven Lacerda 3 years ago 20
When a file has changed, Sublime picks up the change and updates the view. However, the scroll and cursor position are reset to the top.

It would be great if it retained the previous cursor position, even it if was simply the same line & char position (which may be different content following the edit).

Even better, it could try and place the cursor back on the same line even if that line has moved. A diff would provide the info.
It doesn't look like this could be implemented with a plugin currently, since there's no listener for the file reload event in ST2's API: http://www.sublimetext.com/docs/2/api_reference.html#sublime_plugin.EventListener
+11
This has been particularly painful for me lately as I've been switching a lot between a master branch and a feature branch the last couple of weeks. It's really annoying to lose where I am.

I'm totally fine with the line/char position being retained and figuring out the context switch from there. There's a much better change of being in the right area where as going to the top is almost never where I want to be.
+12
Yup. This is bugging me every day in my work. Every time there is new dev version I only look for this bug fix. Please, please please.
+6
It is making for me impossible to work on a mounted network drive, especially when testing scripts and need to save file and refresh web browser every minute or so.

If only reloading the file could be disabled, it would be fine for me...
+5
This suggestion isn't about turning off reloads, it's about keeping the cursor position where it was before the reload. There might be another suggestion on this site for the problem you are experiencing.
+6

I often do modifications in both ST and VisualStudio interchangeably. Mainly because it's much faster to find a file in ST (Go to anywhere rocks while VS Express doesn't have such equivalent) but then I don't have auto-completion in ST so I can't use it all the time.


It's so annoying when after doing some small change in VS, ST scrolls file to the top. Also collapsing (loosing position of) all the bookmarks so that they end up on the first line is a bad issue. Please, please have a look at that.

+13
Can somebody move this to Bugs section? Its invisible in General with 700+ votes topics.
+10
I think it would be fine to simply place the cursor back on the same line as before even if the content of the file changed would be the easiest.  Trying to make ST use diff's to figure out where the previous line was if it moved in the case that the content changed would be a LOT more work.  That would be nice someday but imo just the quick and easy solution would be better in order to push the feature out sooner than later.
-3
I've been using this plugin and it seems to work pretty well
+7
I might be confused (and there isn't much BufferScroll documentation), but it does not seem to be doing what is needed here: keep cursor position after silent file reload.  It seems to be directed towards restoring cursor position after  a file is reopened, which is a different thing. 

Basically I have a log file loaded in the editor, and I would like the cursor to stay where it is instead of scrolling back to the top every time the log is being written to.  Were you able to get BufferScroll to do something like that?
+4
I can confirm this doesn't fix the issue.

This is a deal breaker for me, I work in a company with >10 other devs, a few of us use Sublime Text 2 already (Unregistered) but find this issue extremely frustrating.
Save work, load web page (related to the save), go back to ST2 to look at the code and find the file has been refreshed and the cursor sent to the top of the page.  Ctrl+Z seems to get the cursor back to the correct position but seems a bit lame having to do that every time you check your work.  I (and others) would love to purchase ST2 to support this awesome editor - please fix!
+6
I have to add my support to the request to fix this problem - based upon testing so far, ST2 is awesome, but it is simply not deployable within a production environment when another process merely "touching" a file causes the developer/sys admin to lose their cursor location in their file.
(Here is a valid test to demonstrate the issue;
* open a large file (be it a log file or code file etc)
* position your cursor say, 2,000 or so lines through the code,
* open a terminal, use the "touch" command to touch the file
* look at your code/log again - Oh no! It's been reloaded without your consent and your cursor is now at line1, column1.)

Imagine now that, instead of arbitrarily "touching" the file, it's touched by a process such as reloading the php source via apache because you've edited your code, or your system administrator has just updated a file search index, or the automated backups have just run...

This is especially troubling when in a large log file, code file or data file.  The file doesn't have to have been written to even for this behaviour to kick in...

This is *NOT* a feature - it is a bug and as Woody says, a deal breaker.

We cannot signoff licence purchases for ST2 without resolution of this issue.
+5
Bumping with a plea to fix this. Edit file, alt-tab to browser, ctrl-r, alt-tab to Sublime, lost my spot, slam fist against table.
-5
Just purchased and upgraded to the nightly, looks like it's working so far - thanks :D
+5
Still doesn't work with SublimeExternalCommand, cursor position resets to the top after filtering the buffer.
+2
Ditto to what Sebastian Riedel said.  Version 2.0 Build 2210 still has the problem.  I'm using the PerlTidy package and after execution, the cursor resets.

Seems to be fixed in Version 3.0 Build 308

I am running version 3.2.2 3211 and this is still causing me havoc