How can I lock the position of a tab to prevent it from moving or re-ordering? For example, if I lock tab #1 then I should not be able to move the tab. Thanks.
This is not currently possible without plugins, and I may be wrong here but I don’t think plugins can reasonably prevent dragging a tab around.
can you suggest a plugin?
I’m not aware of any plugins that do this, someone else might be.
Locktab seems to be 5 years old - and there is a pre close tab callback, if I recall correctly - meaning it would be possible to prevent closing a tab if it is locked.
If you use this to prevent closing tabs - I’d recommend altering it to reflect the changes from the last 5 years.
A plugin would be required to accomplish locking a tab to a static position. I’m not sure of any that exist, though…
If you want to create a plugin for this:
I’m not sure whether or not events exist to track when a tab is moved. There are some to track when one is clicked - an easy way to check is to enable developer console output ( I can’t recall the command and it doesn’t appear in my console command history ) which will show everything sublime text is doing – it is how I found which commands / events to track when a user clicks on a line in another tab in an alternate group to jump to a line in the primary group file. It helped me isolate behavior to determine single click vs double-click.
It should be able to output all of the commands / events being executed when you click on a tab, drag it, etc… to see if those events are tracked.
If no events exist to determine if a tab was dragged; that’s ok… We know that a tab can only be dragged after it has been clicked, or a drag has occurred when the user releases the mouse button - and an event exists for the first, and may exist for the second.
If an event only exists for the first, then you simply activate a delayed action in that event and then look at tabs in the current / views’ window ( the view will be provided as an argument, and you can get the window the view belongs to via command on the view object )… From the window, you get the list of tabs, and if any are out of place - you re-order…
I do believe it is possible either by using a nasty hack which would mean ( and the cleanest way instead of closing files, etc… would be to: ) creating a new window, and moving the tabs to it, in the order that you want and then closing the current window ( unless it closes itself when the last tab is moved out of it )… along with copying any important information from the window ( although, if a plugin has set any info to the window, then it should also handle this situation properly ).
But, there should be a way to do what you want without using this ‘hack’. I’ll see if I can find something as I’m working on my problem.
You can’t prevent closing a tab in a hook like that. The pre_close callback, however, is needed to store the tab’s position and then schedule reopening the tab, probably.