Home Download Buy Blog Forum Support

Browser-like back/forward history navigation

Browser-like back/forward history navigation

Postby optilude on Sat Aug 13, 2011 7:50 pm

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: https://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:

Code: Select all
  { "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
optilude
 
Posts: 30
Joined: Sun Jan 30, 2011 2:36 pm

Re: Browser-like back/forward history navigation

Postby ehamiter on Sat Aug 13, 2011 9:53 pm

This is excellent.
ehamiter
 
Posts: 67
Joined: Wed Apr 27, 2011 2:42 am

Re: Browser-like back/forward history navigation

Postby ilya on Sun Aug 14, 2011 7:48 am

Very useful! Thanks!
ilya
 
Posts: 122
Joined: Fri Sep 11, 2009 8:32 pm

Re: Browser-like back/forward history navigation

Postby rchl on Sun Aug 14, 2011 11:35 am

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.
rchl
 
Posts: 147
Joined: Fri Mar 04, 2011 11:02 pm

Re: Browser-like back/forward history navigation

Postby optilude on Sun Aug 14, 2011 3:33 pm

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.
optilude
 
Posts: 30
Joined: Sun Jan 30, 2011 2:36 pm

Re: Browser-like back/forward history navigation

Postby amdtek on Sun Aug 28, 2011 9:23 am

optilude wrote:Code: https://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:

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



Dear Martin,
optilude wrote:Put this in your "Packages" directory and then configure "Key bindings - User" to use it.

You mean within like this?
Code: Select all
../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
Code: Select all
../Packages/
regardless on which environment you are working on or should that navigationHistory.py be placed differently for Windows users under this
Code: Select all
../Packages/User/


Also regarding the keys, what could keys like super be equivalent for windows?
optilude wrote:
Code: Select all
  { "keys": ["super+ctrl+alt+left"], "command": "navigation_history_back"},
  { "keys": ["super+ctrl+alt+right"], "command": "navigation_history_forward"}


Regards,
Anooj.
amdtek
 
Posts: 3
Joined: Sun Aug 28, 2011 8:55 am

Re: Browser-like back/forward history navigation

Postby optilude on Sun Aug 28, 2011 2:21 pm

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
optilude
 
Posts: 30
Joined: Sun Jan 30, 2011 2:36 pm

Re: Browser-like back/forward history navigation

Postby sheldno on Wed Jan 18, 2012 7:45 pm

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? http://wbond.net/sublime_packages/packa ... developers
sheldno
 
Posts: 22
Joined: Thu Oct 06, 2011 4:09 pm

Re: Browser-like back/forward history navigation

Postby temoto on Thu Apr 05, 2012 7:01 pm

Confirm plugin works. Thanks for great job. Please put it on package control.
temoto
 
Posts: 5
Joined: Thu Mar 22, 2012 8:51 am

Re: Browser-like back/forward history navigation

Postby losvedir on Sat Jun 09, 2012 3:07 am

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!). :)
losvedir
 
Posts: 2
Joined: Fri Jul 29, 2011 1:13 pm

Next

Return to Plugin Announcements

Who is online

Users browsing this forum: No registered users and 10 guests