Sublime Forum

Tab Aliases, Numbered Tabs

#1

I would like to assign aliases to tabs something like view.setAlias()
I believed that view.setName() was for this but is NOT. If I change the buffer name sublime thinks the file is a new file and it marks it as unsaved.

Purpose of this is because sometimes I have files that have same ending filename like style.css, so I sublime I would alias them like “{sitename} style.css” “{sitename2} style.css”, etc… is also useful for other purposes, at least in my opinion.

Also if we could get an option for tabs to show numbered tabs that would be better :smiley: that way we just enable the option (temporarily) with the api then disabled it when we don’t need numbered tabs.
(1) filename.css, (2) filename.html, (3) filename.php

Let me know what you guys think :smile:

0 Likes

#2

i think the ability to add comments or marks on tabs can be very useful. so i like your proposal to support alias for tab

0 Likes

#3

Another vote for this. Here is the simplest example I could think of - this marks read-only files on the tab:

class ReadOnlyTracker(sublimeplugin.Plugin): def onLoad(self, view): if not os.access(view.fileName(), os.W_OK): view.setName(os.path.basename(view.fileName()) + ' [R]')
The problem here is that it marks the buffer as dirty and changes the filename. I tried to temporarily do setScratch(True) but the end result was same. So basically what is needed is an API that can change the label of a tab without doing anything else such as marking the file changed or modifying the filename. As a bonus it would be nice (but low priority) if we could add icons/images to tabs :smiley:

0 Likes

#4

Or if your doing your own plugins you can append the current working mode on the tab
filename.php [selection_mode], filename.php [insert_mode]

there’s many many uses for it…

And from the coding side of it, maybe something like this,

view.setAlias(str, start=0])

str:

start (optional) – 0 by default:

examples:

view.setAlias("[R]") == [R]yahooStyle.css view.setAlias("[R]", 0) == [R]yahooStyle.css view.setAlias("[R]", 1) == b[R]oo.css view.setAlias("[R]", 5) == yahoo[R]Style.css view.setAlias("[R]", 6) == google[R]Style.css view.setAlias("[R]", -1) == site.css[R] view.setAlias("[R]", -5) == site[R].css

And taking from example above:

class ReadOnlyTracker(sublimeplugin.Plugin): def onLoad(self, view): if not os.access(view.fileName(), os.W_OK): view.setAlias('[R]', -1)

Jon any input on this?

0 Likes

#5

I’m not trying to necro an old thread, but I do have a strong interest in this feature.

I would love to prepend to or rename the labels of the tabs. I’ve written a plugin that gets the views and iterates over them to build tab numbers, but nowhere to put them :confused:

I like to use cmd+n to get around the tabs, so having the tab numbers would be helpful.

Thanks!

0 Likes

#6

plugin idea:
if the buffer is unmodified, mark it as a scratch buffer so it won’t show up as unsaved.
change the view name with view.set_name.
on_modified, clear the scratch flag.
on_pre_save, rename the view.
on_post_save, set the scratch flag again and rename it back.

Seems like it should work?

0 Likes

#7

After I wrote the previous post, I felt strongly like I remembered having done that exact thing before.
Turns out I had:
github.com/adzenith/Sublime-plu … folding.py
Back before Sublime Text had code folding, I wrote a code folding plugin that did the same trick to show the buffer as unmodified. It worked great.

0 Likes

#8

+1

  • maybe add the numbers also on the sidebar

  • after 0 (10) move on with a, b, c… hotkeys could be like ctrl+q a, ctrl+q b, etc

[quote=“tadfry”]I’m not trying to necro an old thread, but I do have a strong interest in this feature.

I would love to prepend to or rename the labels of the tabs. I’ve written a plugin that gets the views and iterates over them to build tab numbers, but nowhere to put them :confused:

I like to use cmd+n to get around the tabs, so having the tab numbers would be helpful.

Thanks![/quote]

0 Likes

#9

I’d really like some sort of feature, I had an idea for a plugin that could do it, if somebody feels like trying (otherwise I could try it myself when I’ll find the time).

I’m assuming Win as OS, but I guess it should be doable everywhere.

The idea would be to use symlinks, with per project settings:

  • the plugin would keep a list of all files for that project in a json

  • for each entry (the real filename): an alias (the name of the symlink), a “autorename” flag, a “manually set” flag.

  • you could define general renaming rules (eg. hide some extensions, hide a regex in name), this would set the “autorename” flag.

  • or you could manually give an alias to the tab (through context menu, palette, hotkey), this would set the “manually set” flag. A manually given name wouldn’t be altered by per project automatic renaming.

  • the plugin would then create symlinks for all the flagged files (manually or not), in folders recreating your project folder structure.

  • finally would change the filenames to the symlinks for the flagged files. You would read the symlink name, but modify your real file.

  • optionally the plugin could replace all instances of the files in the workspace file, but this is only possible while the project isn’t open.

Any thoughts?

0 Likes