Atom

Introduction

Atom is an open source text editor developed by GitHub. It’s a lightweight text editor that’s free to use.

Install

Visit Atom’s website and follow the instructions to install it on your computer.

Example: greet.py

By now, you should have Atom installed. You have the option of either finding the Application or opening it up from the terminal. Recall from Lab 00 that you can open a terminal on the school computers by pressing Ctrl-Alt-t.

Let’s first create and navigate to a directory called example, using the UNIX commands you learned in Lab 00:

mkdir ~/example
cd ~/example

Opening a project

Now let’s open up Atom!

For Mac users, you’ll most likely find Atom in your Applications.

For Ubuntu users, you’ll most likely find Atom by putting it in the search bar.

For Windows users, you’ll most likely find Atom in your Program Files.

Click on “File > Add Project Folder…” in the menu bar. Highlight the example folder you just made and open it. It should appear in the sidebar as an empty folder.

empty atom{.img-responsive .center-block}

Editing files

Now we have Atom open, we can begin writing our first Python file. We’ll be writing a short program that prints out a greeting when executed. Don’t worry, we don’t expect you to know any Python yet! All you have to do is type in the following:

def greet(name):
print('Hi', name, ', how are you doing?')
print(' - Python')

Once you’ve finished typing, Atom should look something like this:

atom greet

To save, you can just type Ctrl-s. If you haven’t already, save this file as greet.py in the example folder. Notice that it appears in the sidebar under example! This will be helpful for navigating projects that are more than one file.

Running Python

Back in our terminal, we’re currently in our example directory. Let’s play around with our code. In the terminal, start by typing

python3 -i greet.py

This command does the following:

  1. python3 is the command that starts Python
  2. The -i flag tells Python to start in interactive mode, which allows you to type in Python commands from your terminal
  3. greet.py is the name of the Python file we want to load

Notice that the Python interpreter says >>>. This means Python is ready to take a command.

Recall that we defined a function called greet. Let’s see what it does! Type in the following:

>>> greet('Michelle')

Python will then print out

Hi Michelle, how are you doing?
- Python

Our code works! Let’s close Python by typing in

>>> exit()

There are a couple of ways to exit Python. You can type in exit() or quit(). On MacOS and Linux, you can also type in Ctrl-d (this doesn’t work on Windows).

Congratulations, you’ve edited your first file!

Keyboard Shortcuts

For Mac users, replace all the Ctrl sequences with cmd

  • Ctrl-s : saves the current file
  • Ctrl-z : undo
  • Ctrl-y : redo
  • Ctrl-[ : indent a line or a group of lines
  • Ctrl-] : dedent a line or a group of lines
  • Ctrl-tab : moves you to the next tab
  • Ctrl-shift-tab : moves you to the previous tab
  • Ctrl-f : search for a word
  • Ctrl-shift-f : searches through all tabs
  • Ctrl-shift-p : This one’s important. This opens up a little panel of tools! You can do things like type “ss python” which will set the syntax of your file to python or “reindent” will help you reindent a file you paste in (this will be helpful in future labs!)

This guide only scratches the surface of Atom’s functionality. If you are interested in diving deeper into Atom, check out it’s documentation! Remember, if there’s something you wish Atom could do, it probably can! Just Google it!

Pair Programming

Atom provides the Teletype package for code collaboration

You can install it by opening up the Settings view, clicking on the Install tab, searching for teletype, and clicking “Install”. You can also click this direct link to find the teletype package.

Once installed, there will be a portal icon in the Atom status bar that looks like a wireless tower. One partner clicks that icon to create a portal and shares the link with the other partner. The partners can then begin collaborating together.

© 2024 Brigham Young University, All Rights Reserved