Skip to content

The code editor

The editor is where you write your program. It colours your Python code, shows line numbers, and looks after the spaces at the start of each line for you.

Your project's files

Beside the editor, Files lists your project's files and folders. Choose a file to open it in the editor, or a folder to work in it. Pictures and sounds cannot be opened here yet.

The buttons above the list do these things. Hold the pointer over one to see its name.

Button Name What it does
📄 New file Makes an empty file in the chosen folder.
📁 New folder Makes an empty folder in the chosen folder.
✎ Rename Changes the name of the chosen file or folder.
🗑 Delete Deletes the chosen file or folder, after asking.

You can also right-click a file or folder for a menu with the same four choices. Right-click the empty space below the list to make a file or folder at the top of the project. With the keyboard, choose a file or folder and press the menu key, or Shift+F10, then use the arrow keys and Enter. Esc closes the menu.

  • A new file or folder starts in the chosen folder. To put it somewhere else, change the start of its path, such as levels/one.txt. Any folder the path names is made for you.
  • Rename shows the whole path, so you can move a file or folder by changing the folder part, such as ball.png to images/ball.png. A file stays a file and a folder stays a folder.
  • Delete asks first. For a folder, it says how many files are in it. Deleting cannot be undone.

main.py is where every program starts, so it cannot be renamed, moved or deleted. A folder stays when you move or delete the last file in it, until you delete the folder itself.

Every name must work on Windows, macOS and Linux, because your project may be opened on any of them. So pygwide refuses a name that:

  • is blank, or uses any of < > : " | ? * \;
  • starts or ends with a space, or ends with a dot;
  • is one Windows keeps for itself, such as con or lpt1;
  • is the same as another file or folder, even if only the capital letters are different, such as Ball.png and ball.png;
  • is pygwide.json at the top of the project, which pygwide keeps for the project's details.

A file must also be a type a project can hold: Python (.py), pictures (.png, .jpg, .jpeg, .gif, .bmp), sounds (.wav, .ogg, .mp3), fonts (.ttf, .otf), or text and data (.txt, .md, .json, .csv). So you cannot make or rename a file to tool.exe, or to notes with no ending. A folder's name has no type, so any name allowed above will do.

Indenting

Python uses the spaces at the start of a line to group code. The editor always uses four spaces for each level, and never a tab character, so your program cannot fail with a TabError.

  • Press Enter after a line ending in :, such as if score > 10:, and the next line starts indented.
  • Press Backspace in the spaces at the start of a line to remove one whole level.
  • Press Tab to add four spaces, or select some lines first to indent them all. Shift+Tab takes a level away.
  • If you paste code that has tab characters in it, each tab becomes four spaces.

Keyboard shortcuts

On a Mac, use the key in the Mac column. Holding Shift with any of the moving keys selects the text as the cursor moves.

Running

Keys Mac What it does
Ctrl+Enter Ctrl+Enter Run the program, wherever you are on the page

Saving

Keys Mac What it does
Ctrl+S Cmd+S Save your work in this browser now. It also saves by itself.

Your work is saved only in this browser. To keep a copy you can take away, use ⇩ Export. If the browser cannot save it, such as when its storage is full, pygwide says so, and exporting is the way to keep it.

Undo and redo

Keys Mac What it does
Ctrl+Z Cmd+Z Undo your last change
Ctrl+Y Cmd+Shift+Z Redo the change you undid
Ctrl+U Cmd+U Undo the last change to what is selected
Alt+U Cmd+Shift+U Redo the change to what is selected

Each file remembers its own changes, so undo still works after you switch to another file and back.

Moving around

Keys Mac What it does
Arrow keys Arrow keys Move one character or one line
Ctrl+Left, Ctrl+Right Alt+Left, Alt+Right Move one word
Alt+Left, Alt+Right Ctrl+Left, Ctrl+Right Move over a whole word or bracketed part of the code
Home Cmd+Left Go to the start of the line
End Cmd+Right Go to the end of the line
Ctrl+Home Cmd+Up Go to the start of the file
Ctrl+End Cmd+Down Go to the end of the file
Page Up, Page Down Page Up, Page Down Move up or down one screen
Ctrl+Shift+\ Cmd+Shift+\ Jump to the bracket that matches the one next to the cursor

Selecting

Keys Mac What it does
Shift with a moving key Shift with a moving key Select as you move
Ctrl+A Cmd+A Select the whole file
Alt+L Ctrl+L Select the whole line
Ctrl+I Cmd+I Select more: the word, then the code around it
Ctrl+Alt+Up, Ctrl+Alt+Down Cmd+Alt+Up, Cmd+Alt+Down Add another cursor on the line above or below
Esc Esc Go back to a single cursor

Changing lines

Keys Mac What it does
Enter Enter Start a new line, indented to match
Tab Tab Add four spaces, or indent the selected lines
Shift+Tab Shift+Tab Remove one level of indent
Ctrl+] Cmd+] Indent the line
Ctrl+[ Cmd+[ Remove one level of indent from the line
Ctrl+Alt+\ Cmd+Alt+\ Fix the indent of the selected lines
Alt+Up, Alt+Down Alt+Up, Alt+Down Move the line up or down
Shift+Alt+Up, Shift+Alt+Down Shift+Alt+Up, Shift+Alt+Down Copy the line above or below
Ctrl+Shift+K Cmd+Shift+K Delete the line
Ctrl+/ Cmd+/ Turn the selected lines into comments, or back into code
Backspace Backspace Delete the character before the cursor, or one level of indent
Delete Delete Delete the character after the cursor
Ctrl+Backspace Alt+Backspace Delete the word before the cursor
Ctrl+Delete Alt+Delete Delete the word after the cursor
— Cmd+Backspace Delete back to the start of the line
— Cmd+Delete Delete on to the end of the line

Leaving the editor with the keyboard

In the editor, Tab indents your code. To move to the next part of the page instead, press Esc, then Tab.

Ctrl+M (on a Mac, Shift+Alt+M) switches Tab between indenting and moving around the page. Press it again to switch back.