Sublime Forum

Browser-like back/forward history navigation

#1

Hi,

Following the discussion in this thread, I’ve implemented a navigation plugin that allows you to navigate back and forward in a browser-like manner.

Code: github.com/optilude/SublimeText … History.py

Put this in your “Packages” directory and then configure “Key bindings - User” to use it. I use these keybindings for it on OS X:

  { "keys": "super+ctrl+alt+left"], "command": "navigation_history_back"},
  { "keys": "super+ctrl+alt+right"], "command": "navigation_history_forward"}

It works like this:

  • Whenever you navigate (change selection/move the caret) to a location that differs to the previous selection location by more than 2 lines or is in a different file, a history entry is made (this stops history entries from being created every time you type something or use the arrow keys to navigate around)

  • Go back in history, use the navigation_history_back command. I’ve bound this to cmd+alt+ctrl+left above

  • Go forward in history, use the navigation_history_forward command. I’ve bound this to cmd+alt+ctrl+right above

  • You can go back and forth multiple times, but as soon as a new history entry is recorded (i.e. you just somewhere else), the forward history is cleared

  • History is per-window, so it works across files in the same window/project, but not between windows

Feedback/forks/improvements welcome.

Martin

0 Likes

Web browser-like history to go back to the previous focus
#2

This is excellent.

0 Likes

#3

Very useful! Thanks!

0 Likes

#4

Very nice idea. Biggest problem I have with it is that when doing inline search it saves all intermediate positions to which editor jumps while typing a word.

0 Likes

#5

Interesting problem. It’s possibly hard to deal with that, unless there’s some way to check whether an inline search is currently active in the “on selection changed” event hook.

0 Likes

#6

Dear Martin,

You mean within like this? ../Packages/User/
Based from your post, I am guessing you must be most probably working on an OS X machine. I am on Windows and it should be like I showed, at least that’s what I think. I never used a Mac. Maybe for OS X & Windows users, it differs a bit.

Please share me your inputs and tell whether it should always be generic, i.e. to always be within ../Packages/ regardless on which environment you are working on or should that navigationHistory.py be placed differently for Windows users under this ../Packages/User/

Also regarding the keys, what could keys like super be equivalent for windows?

[quote=“optilude”] { "keys": "super+ctrl+alt+left"], "command": "navigation_history_back"}, { "keys": "super+ctrl+alt+right"], "command": "navigation_history_forward"}
[/quote]

Regards,
Anooj.

0 Likes

#7

Hi,

I don’t really know as I’ve not used Sublime Text on Windows.

The ‘super’ key is the command key. I’d probably use cmd+alt+shift with left or right on Windows.

Martin

0 Likes

#8

Does this plugin still work? It doesn’t seem to do anything for me.

p.s. if it’s still maintained maybe consider adding it to package control? wbond.net/sublime_packages/packa … developers

0 Likes

#9

Confirm plugin works. Thanks for great job. Please put it on package control.

0 Likes

#10

Just wanted to chime in here with a great big “Thank You!”. I’ve been using your plug-in this week and it’s been great.

The amazing thing that prompted me to write this post was when I accidentally closed a tab. I hit cmd-z and cmd-shift-t, my two muscle memory commands to undo a closed tab (safari and chrome, respectively), but neither worked. But then I realized I had just been editing that tab and tried going “back”. And it worked!

So, great plug-in. I encourage others to give it a try, and maybe jon to include similar functionality at some point (pretty please!). :smile:

0 Likes

#11

Cool plugin but it doesn’t seem to work with split panes :\

0 Likes

#12

I would love to have this functionality, but it doesn’t seem to work in 2.0.1 build 2217 (or else I’m a unique case). :frowning:

0 Likes

#13

Kudos - awesome plugin.

0 Likes

#14

For me it’s rather cumbersome that it switches to a different tab when I have more than one open (and made edits in both / multiple tabs).
Could the source be changed so that it doesn’t switches tabs but when it has reached the last known history entry in the current tab, it just stays at that position?

0 Likes

#15

Excellent! Thanks

0 Likes

#16

Wow, works like charm… thanks a lot!!

0 Likes