Philadelphia Python Workshop/Setup/Linux text editor

From OpenHatch wiki
Jump to navigation Jump to search

Our Recommendation[edit]

On Linux, we suggest using Sublime, Komodo Edit, or GEdit. Sublime and Komodo Edit have more advanced features, but GEdit is already installed on Ubuntu. All can be used for free, though Sublime has an indefinite free trial period and requests that you purchase a license (you can ignore this for now).

Sublime[edit]

Sublime Text is available from Sublime's web page. It has a (non-free) license, but you can use the free trial period for as long as you like.

Installation[edit]

  • Go to the main page and click on the blue button that says "Download for Linux".
  • Save the file to your desktop (or another convenient location).
  • Double click on the file to extract it, then open the extracted folder called Sublime Text 2.
  • To run Sublime, double-click on the executable file sublime_text.
  • If a text-editor window doesn't pop up, let a staff member know.

Setup[edit]

  • If it's not running, double-click on sublime_text.
  • From the top menu, click Preferences, then click Settings - Default. A new tab will open with text and options in it.
  • Scroll down until you see the line "translate_tabs_to_spaces": false,
  • On that line, change false to true so that it reads "translate_tabs_to_spaces": true,
  • Save the settings by pressing Ctrl+s or clicking on File, then Save.
  • Now every time you press the tab key, it should insert four spaces instead of a tab.

Komodo Edit[edit]

Komodo Edit is a free editor available from Active State.

Installation[edit]

  • Go to the downloads page and click on the blue button that says "Download Komodo Edit 8.0.1 for Linux".
  • Save the file to your desktop (or another convenient location).
  • Double click on the file to extract it, then open the extracted folder.
  • The official instructions are in the install.html file.
    • If you are comfortable with using a command prompt you can follow those instructions to install the program.
    • Otherwise, open the INSTLLDIR folder, then open the bin folder. Double-click the file komodo to start the program.
  • If the program does not run, ask a staff member for assistance.

Setup[edit]

  • Once Komodo is running, click on Edit in the menu, then select Preferences.
  • On the left-side menu, click on Editor to expand it, then click on Indentation
  • In both Global Indentation Settings and Per Language Indentation Settings, make sure Prefer Tab characters over spaces is UNchecked, and make sure both fields for Number of spaces per indent and Width of each Tab character are 4.
  • Click on OK. Now the editor should add four spaces instead of a tab character when you press the tab button.
  • To open a file, click on the New File label in the lower right. Select Python (not Python3) from the menu and then click open.
  • A new file should open with #!/usr/bin/env python as the first line. This is a comment, and can be deleted or ignored.
  • If a new file doesn't open, ask a staff member for assistance.

GEdit[edit]

How to find GEdit in the Applications list[edit]

GEdit should already be installed on your computer. To start GEdit: click Applications, point to Accessories, and click Text Editor. If you don't have this option, let a staff member know.

How to find GEdit from a terminal[edit]

If you prefer to start applications from a terminal, you can type the following into a terminal to launch GEdit:

gedit &

Configure GEdit to indent with spaces[edit]

  • Click Edit -> Preferences
  • Select the tab labeled "Editor"
  • In the "Tab width" field, set it to 4 (the default is 8)
  • Check the box labeled "Insert spaces instead of tabs"
  • Check the box labeled "Enable automatic indentation"
  • Click Close.

That's it! Now, you can hit tab to indent your code, and that indentation will actually be made of spaces. This change will help you use spaces consistently, so that Python doesn't get confused about whitespace.

Success![edit]

If you prefer a different editor for text, check with an instructor before moving on to make sure it will work for the weekend.

« Back to the Friday setup page