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
Asked
Active
Viewed 6,078 times
11
-
1Did 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. – rgrwkmn Feb 06 '15 at 22:58
-
3Here is a link to a plugin that I wrote to do this: [Set Name Of Unsaved Buffer](https://github.com/mattst/sublime-set-name-of-unsaved-buffer) – mattst Apr 25 '16 at 16:51
-
As a workaround, it is possible to use sidebar instead of tabs. – john c. j. Apr 08 '17 at 13:47
1 Answers
15
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.

skuroda
- 19,514
- 4
- 50
- 34
-
@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?) – Steve S Jul 29 '14 at 22:21
-
@SteveS The renaming only effects the tab name, not the file name itself. – skuroda Aug 02 '14 at 05:13
-
@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? – Steve S Aug 02 '14 at 05:29
-
@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. – skuroda Aug 04 '14 at 02:18
-
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"? – Steve S Aug 04 '14 at 02:54
-
@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. – skuroda Aug 05 '14 at 06:37
-
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. – Goran Usljebrka Feb 16 '20 at 09:05