Hallo vrienden, Leo here.
This week my friend Tales teach me about one Xcode feature that bugged my head for a long time. Did you notice that sometimes you open a new file in a new tab and sometimes you open new files replacing the tab you are working on? Yes, this feature is the permanent and temporary Tabs and that's what we will talk about today. No code for today but don't worry, more coding will coming in the next weeks.
The painting I choose was a 1926 named Boy and Girl gazing at the Moon from Norman Rockwell. Norman Perceval Rockwell was a 20th-century American author, painter, and illustrator. His work is loved by Americans for its reflection of American culture, making him one of the most famous artists of the USA. Looking at Rockwell's love for provincial life, one could imagine he was born and raised on a farm. But in fact, he was born in New York City, and raised in a popular neighborhood, experiencing all the violence of city gangs.
I choose it because represent children represent the both types of tabs in Xcode. Two tab types, two children in the painting. :)
You are reading a tab X and want to open another file but that file replaces the tab X.
Imagine that you have this file structure:
And you single click in ViewController.swift:
Did you notice that the ViewController.swit name in the tab bar is italic? But why is that?
The Xcode have this feature called permanent and temporary tabs. This means that every open tab is in one state or another. When a tab is in italic means that's is a temporary tab and when isn't it's a permanent/regular tab. Every time you open a new file (with shortcuts like shift+cmmd+O or in the Project Navigator) the Xcode will choose between open a new tab or replace the current temporary tab with the new file.
The temporary tab represent something that can be discarded, so if you try to open another tab it will replace the temporary tab. This is good to not flood you Xcode with thousand open tabs and organizes the dev workbench.
To open a file as a temporary tab you just need to single-click in the Project Navigator, like the image above. Your file open in a temporary tab and if you single-click again in another file in the Project Navigator the other file will replace the actual.
The permanent tabs as the name say are permanent. They won't be replaced by new ones if you try to open any other file. There's a several ways to turn a temporary tab into a permanent one, let's see:
- Double-click on the file in the Project Navigator when the file is not open.
- You can also double-click on the Project Navigator in an already open file to make it permanent.
- Double-click in the tab itself.
- Right-click on the tab and select "Keep Open".
- Edit/Write something in the file of the temporary tab will turn it into a permanent tab.
One curiosity is that you can have only one temporary tab open and from the moment the tab is permanent it will never become a temporary again.
This week post was a feature about Xcode and workbench cleanliness and I hope you like it. I found it very interesting and now I know why sometimes the file open in another tab or not.
That's all my people, I hope you liked as I enjoyed write this article. If you want to support this blog you can Buy Me a Coffee or just leave a comment saying hello. You can also sponsor posts and I'm open to
writing freelancing! Just reach me in LinkedIn or Twitter for details.
Thanks for the reading and... That's all folks.
Did you find this article valuable?
Support Leonardo Maia Pugliese by becoming a sponsor. Any amount is appreciated!