Sublime Forum

Saving files

#1

I am just starting to us Sublime text. When I type a simple command such as Print(‘hello world’) and then try to save it, I get an error message that permission has been denied. How do I get around this problem.

0 Likes

#2

If you’re on a Mac or Linux, the reason for this is that you’re probably trying to save a file at the root of the file system / or some other restricted location; on those systems permission to write to places like that is restricted to Administrators because fiddling with files in the wrong places can break the machine.

If that’s the case, you should try to save files in your Home directory instead; the file save dialog should have a button in it that will take you to your Home directory (it usually has a :house: icon on it).

On Windows the same thing can happen if you try to save files into inappropriate locations, the most likely of which would be if you try to save a file into something that’s contained in the Program Files directory (for example if you try to save a file in the location where Sublime is installed).

The fix there would be the same, although there is no Home button and isntead you’d want to pick a place like your Desktop or (better) create a folder in the Documents folder and put your files in there.

0 Likes

#3

I was able to save the file without a permissions error but then I couldn’t run the program. I couldn’t find a run command in the file menu. I apparently am missing something.

0 Likes

#4

You use a build system to execute external programs in Sublime (like a Python interpreter or such). You can use Tools > Build System to select the build system to use (Automatic tells Sublime to determine that on its own) and then Tools > Build to actually run it. You can see the key binding for that in the menu.

0 Likes

#5

If you saved the file with a .py extension, just press CTRL-B to run it.(while the file is displayed in Sublime Text.)

0 Likes

#6

Forgive me if i’m asking the obvious. Let’s take the simple 2-line “Hello World” as an example. How should I save my file as? As a .py file or as the .sublime-project? The default location seems to be at the “Package Control.cache” folder; I suppose I can just save it in any documents folder in my device? Thanks in advance!

0 Likes

#7

File extensions are what most programs use to determine what the type of a particular file is, so you should always save your files using an extension appropriate to their content.

For example, Python programs should be saved with a .py extension because anything that sees a .py file will assume that it’s Python. Similarly if Sublime sees a sublime-project file,it’s going to assume that it’s a Sublime project (which contains information on folders that you have open and such).

Sometimes files need to be in a specific location and so the place you save them is important (for example, Sublime only looks for plugins in very specific places and doesn’t see them otherwise) but generally speaking the location you save files to is more or less up to you. Some locations may be restricted for various reasons, in which case attempts to save files there will fail.

That said, generally speaking you probably want to save files either onto your desktop or into a folder somewhere in your Home directory or Documents folder unless you know they’re supposed to go into a specific place.

0 Likes

#8

Thank you OdaNurd!!

0 Likes