Sublime Forum

Can't save txt files on Windows 10 - saves w/o file extension

#1

Files aren’t saving correctly. When I choose Plain Text as a file type from the drop-down menu, it saves, but the file doesn’t show up in Windows Explorer as a txt file. It just shows up as “File”, not “Text File.” Although I can open it with Sublime Text 3, other files can’t read it.

I tried to have a program iterate through a txt file I saved with Sublime Text 3 but my program couldn’t find the file. After I opened the text file with NotePad++ and resaved it as a txt file, it worked. My program could use it.

Something wrong with Sublime Text 3 and Windows 10?

What might be the issue?

0 Likes

#2

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:

  1. 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
  2. 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)
  3. 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
  4. 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.

1 Like

#3
1 Like

#4

Thank you! Adding the txt extension manually fixed the issue. An extra step, but that’s OK. ST3 works great otherwise. Again, thank you…

0 Likes

#5

Thank you for sharing that. It’s nice to see that other folks had encountered the issue also. Maybe some time they’ll fix the automatic txt extension when someone chooses Plain Text. Fingers crossed?

0 Likes