First Install For Your OS
Atom on Mac
Atom was originally built for Mac and should be a simple setup process. You can either hit the download button from the atom.io site or you can go to the Atom releases page at:
Here you can download the
atom-mac.zip file explicitly.
Once you have that file, you can click on it to extract the binary and then drag the new
Atom application into your “Applications” folder.
When you first open Atom, it will try to install the
apm commands for use in the terminal. In some cases, Atom might not be able to install these commands because it needs an administrator password. To check if Atom was able to install the
atom command, for example, open a terminal window and type
which atom. If the
atom command has been installed, you’ll see something like this:
$ which atom
atom command wasn’t installed, the
which command won’t return anything:
$ which atom
To install the
apm commands, run “Window: Install Shell Commands” from the Command Palette, (cmd + shift + p), which will prompt you for an administrator password.
Atom on Linux
To install Atom on Linux, you can download a Debian package or RPM package either from the main Atom website at atom.io or from the Atom project releases page at https://github.com/atom/atom/releases.
On Debian, you would install the Debian package with
$ sudo dpkg -i atom-amd64.deb
On RedHat or another RPM based system, you would use the
rpm -i command:
$ rpm -i atom.x86_64.rpm
Atom from Source
If none of those options works for you or you just want to build Atom from source, you can also do that.
There are detailed and up to date build instructions for Mac, Windows, Linux and FreeBSD at: https://github.com/atom/atom/tree/master/docs/build-instructions
In general, you need Git, a C++ toolchain, and Node to build it. See the repository documentation for detailed instructions.
Setting up a Proxy
If you’re using a proxy, you can configure apm (Atom Package Manager) to use it by setting the
https-proxy config in your
https-proxy = https://126.96.36.199:0
If you are behind a firewall and seeing SSL errors when installing packages, you can disable strict SSL by putting the following in your
strict-ssl = false
You can run
apm config get https-proxy to verify it has been set correctly, and running
apm config list lists all custom config settings.
Edit a Python file and use Atom’s Autocomplete
Let’s start by creating a Python file with:
$ atom pyfile.py
This will open the file in Atom, and you’ll see the containing folder with all its contents on the left sidebar.
In the new file, if you type de, you’ll see that it suggests if you want to create a new function. This is because Atom has detected that the file extension is a Python extension.
If you type the Tab key, you’ll see a template for a new function:
Note that you have the fname highlighted. This is because you can now type the name of your function and it will replace fname. Let’s name our function product.
Next, if you hit the Tab key again, the arguments of the function, arg, will be now selected. Just write x, y, as we need two different arguments for our function.
Finally, hit the Tab key again to select the body of our function, pass, and replace it for our code. The end function should be something like:
return x * y
Also notice the blue circle next to the file name. This means that there are unsaved changes in your current file. You can save it just typing the usual cmd+s (or ctrl+s in windows).
Linter for Atom
Linter is an Atom package that provides a top level API so that there is a unification among all the linter atom plugins. This means that all the extra packages that you install, that highlight your code (for example to detect errors) will use a unified method.
To install it, just type:
$ apm install linter
Next, we’re going to install a Python Linter package, to help us detect errors in our Python code.
This package is called linter-flake8 and it’s an interface to flake8. To install it, you need to run:
$ pip install flake8
$ pip install flake8–docstrings
$ apm install linter–flake8
You must restart Atom to see the changes. For example, if we add the following line of code in our file:
without specifying what a or b are, we’ll see the following in our Atom screen:
If you open Atom and you find an error that says
The linter binary flake8 cannot be found
You will need to open the Atom init script (Atom –> Open your Init Script) and write the following:
process.env.PATH = [‘/usr/local/bin/’, process.env.PATH].join(‘:’)
Restart Atom the apply these changes. It should work now ????
Further customisation for Python to follow PEP8
Here I’ll show you how you can configure Atom to follow PEP8, the official Python styling guide.
First, open the Atom –> Preferences window.
1. Use spaces instead of tabs.
Scroll down the Settings panel until you see the Soft Tabs option. Make sure it’s checked. This setting will convert tabs into spaces automatically.
2. Set the tab length to 4 spaces
A little below the Soft Tab setting, you”ll see the Tab Length. Set it to 4 spaces.
3. Automatic PEP8 validation.
If you installed the linter-flake8 package discussed in the previous section, you already have automatic PEP8 validation
In the same Preferences panel, you can see the Keybindings menu on the left. There, you’ll find a list of all the default keybindings active in your Atom editor.
However, by default, Atom confirms an autocomplete suggestion with both the Tab and Enter keys. But I only want to use the Tab key.
In order to disable Enter as an autocomplete confirm key, we need to go to the Keybindings menu where you’ll see a link that says your keymap file. Click on that link to open the keymap.cson file.
There, you need to write:
# Disable Enter key for confirming an autocomplete suggestion
Save the file and you’ll see the changes immediately. No need to restart Atom
Other Useful Packages
Project manager: a package for saving your projects.
Atom Django: Django support for Atom
Minimap: Displays a small map of the current file on the right side of your document (like Sublime Text by default).
Script: Lets you run python scripts in Atom
Beautifier: Autocorrect your PEP8 lint errors
$ pip install autopep8
$ apm install atom-beautify