Sublime Forum

How to restore cursor position on open file

#1

Good day commander !

How to restore cursor position on open file ?
Is there any plugin ?
Cant find them
thx

0 Likes

#2

I believe by default ST should restore any cursors, (multi-)selections you have made in any open files. You don’t require a plugin for that.

0 Likes

#3

no, they dont
maybe, is there option for it ?
maybe some plugins disabled it ?..

0 Likes

#4

Cursors are rested when ST is restarted or a workspace is re-opened, but for files that have been closed the selection, edit history, etc. is discarded.

0 Likes

#5

VISUAL STUDIO CODE work propertly…
Sublime Text 4 dont…

no one solution found

0 Likes

#6

VS Code indeed seems to restore selections for closed files. You could file a feature request, though https://github.com/sublimehq/sublime_text/issues

0 Likes

#7

I dont need restore selection, I need restore cursor position only

0 Likes

#8

For all intents & purposes, they refer to the same thing. A cursor is just an empty selection of length 0.

Anyways, your best bet is to open a feature request as stated above, because as also stated by bscaaf, ST doesn’t retain those information when the document closes.

0 Likes

#9

This is actually the very first plugin I wrote because it’s a highly desirable feature which IMO should be provided by default:
https://gmpy.dev/blog/2022/sublime-text-remember-cursor-position-plugin
Since then (2022) I extended it a bit (e.g. added support to restore bookmarks and viewport pos), but I didn’t open source it yet. There are circumstances such as LSP goto command where you don’t want to restore position. Anyway, for basic needs it does it jobs (plus you can modify it).

Note: there’s a plugin called BufferScroll (https://github.com/titoBouzout/BufferScroll) which does this, but to my experience is broken.

0 Likes