How can I change tab name in Sublime Text?
Asked Answered
V

1

11

Is it possible to change tab names for files with strange names? They can not be renamed on disk but it is difficult to keep up with mad file names in Sublime :D

Vulgarism answered 25/4, 2014 at 9:8 Comment(3)
Did you ever find a way to do this? I've been googling my heart out and your question is the only thing I've found that addresses changing the filename shown in a file's tab.Recurrent
Here is a link to a plugin that I wrote to do this: Set Name Of Unsaved BufferInstrumental
As a workaround, it is possible to use sidebar instead of tabs.Suavity
H
17

In the ST console, enter view.set_name("My changed name"), replacing the content of the string with the name you want. You can also create a plugin to do this, again using the view#set_name api method.

Hutner answered 25/4, 2014 at 16:53 Comment(7)
@skuroda: After you've renamed the file using your method, how do you save it? (Wouldn't you have to re-save it under the original name?)Herzl
@SteveS The renaming only effects the tab name, not the file name itself.Hutner
@skuroda: Thanks for your response. I mention that because when I rename the file (which works) but then later try to save it (with CMD+S), it acts as though I just clicked "Save As" with the new tab name as the name in the box. Then, when I try to save it under its a original name, my new tab name goes back to the old filename. Does this make sense? And, is this the same behavior that you experience?Herzl
@SteveS Hmm apparently, I was wrong. I haven't done much (new stuff) with the ST API in quite some time. I had thought it only changed the buffer name, not the underlying filename. I manually verified in the same way you described and had the same behavior. My apologies for the inaccurate information. I have have been setting the file to "scratch", so there wasn't a file to save.Hutner
It's no problem. In fact, I still appreciate the answer (plus it's nice to know I'm not doing something totally wrong)... What do you mean by "setting it to scratch"?Herzl
@SteveS set_scratch is a view method. It allows you to turn the view into "scratch space", so there isn't necessarily a file backing it. For example, create a new file and in the ST console enter, view.set_scratch(True). Make some edit then close the file. Normally this would prompt for saving. However, as it is scratch space, it will not.Hutner
Bear in mind that using the above method will rename all all tabs that are editing that file. If you have that file opened 5 times, all 5 tabs will change name.Superimposed

© 2022 - 2024 — McMap. All rights reserved.