As your post title correctly surmises, your problem is that you’re saving the file without an extension.
Short answer
There is nothing wrong, things are working as designed (if not expected), make sure that when you create a new text file in Sublime that you manually specify that the extension is .txt
by entering it on the end of the file name.
Long windows answer
Windows determines the type of a file based on the extension that it has; bob.txt
is a text file, bob.html
is an HTML file, bob.doc
is a word document, and so on.
When you save a file for the first time as a plain text file, Sublime doesn’t include a default extension for the file, so if you don’t explicitly put .txt
on the end of the file name, your file gets no extension, which means that Windows doesn’t know what kind of file it is (this is why it just says “file”).
If double clicking such a file opens it in sublime (or some other application like Notepad++), it’s probably because the first time this happened Windows said “I don’t know what kind of file this is, how do I open it?” and you picked, e.g. “Sublime Text” from the list that it showed you.
Here’s a likely sequence of events that explains what you experienced:
- You create a brand new text file and try to save it; Sublime prompts you for the file name and you enter
bob
and hit enter, thinking it will save as bob.txt
but actually it saves as bob
- You run a program that you’ve written and tell it to open
bob.txt
, but it fails because there is no such file (the file is named bob
)
- You open the file in Notepad++ and save it, and when you save it, the file gets an extension of
.txt
appended, so the file is now bob.txt
- Your program works as expected because now the file name is different.
This sort of problem is fairly common because by default Windows is configured to hide the extensions of file types (this was historically true; I have no experience with Windows 10 but I assume it’s the same).
Once you associate a file with no extension like this to the application that you expect to use to open it, the file icon changes to the icon you expect and suddenly you have no visual clues at all (except for possibly noticing that it says File
instead of Text File
) that it’s got the wrong name.