+2

Auto add extension based on selected Syntax

Michael Savich 6 years ago updated 6 years ago 9

When I go to save a document in Textastic, I feel it should default to the file extension of the language syntax I have selected. After all, if the user is writing in Python, 90% of the time they'll want to use .py right?

Actually, it should do that already. Are you using the latest version (2.0)?


Do you have "Hide Extension" disabled? If it is enabled, the extension isn't displayed in the save panel.

Yeah, that seems to work, thanks! …but now I notice that the files saved with the extension hidden in Textastic can't be unhidden in Finder. They would appear to be extensionless.

Actually, it was working earlier, but now it's not... When I try to save a document it tries to save it as a txt instead of py, even if python is set as the syntax.

AHA! I figured it out! When you start up the program, it has the last syntax you were using selected, but for some reason the default extension behavior only happens after you select a syntax- so if you launch the program, start a new document, and the syntax is already selected, the program will try to save as .txt That has to be a bug.

I think something different happened here: If you change the syntax definition of a file that is already saved, for example a file with a ".txt" extension, the new newly selected syntax is set as the default for the ".txt" extension instead of "Plain Text".


If you create a new, untitled file, Textastic creates a .txt file. If you earlier set the syntax of a .txt file to "Python", this syntax will be used for it.


To fix this problem, open a .txt file from disk and change the syntax from "Python" to "Plain Text" to restore the default.



The reason for this feature is that for example, for ".h" files, Textastic defaults to the "C" syntax definition. If you change it to "Objective-C" however, it will open all subsequently opened ".h" files with the "Objective-C" syntax.


I hope it makes sense :)

Oh, that appears to have been the issue. You should probably document that in the help when you get around to it. Thanks for the help, btw.

I've been observing the behavior of this application for a while and I noticed if I open it up and the default syntax is "Plain Text", if I type anything, like "#!/usr/bin/python" and change the syntax to say, "Python", the default syntax for plain text becomes python even if I haven't saved it yet. As a workaround, I've been changing the syntax before typing anything in. I suspect this is an issue with autosave- but the behavior is undesirable nonetheless.

Do you have iCloud enabled? The AutoSave behavior of Untitled files might be different depending on whether iCloud is enabled or not.

Yeah, I have iCloud enabled.