Nauč se Python > Materiály > Snake Workshop for PyLadies > Preparation > Editor installation > Gedit

Installation of Gedit #

On Linux, Gedit is installed like any other program.

Fedora
$ sudo dnf install gedit
Ubuntu:
$ sudo apt-get install gedit

If you use a different Linux, I assume that you know how to install programs. :)

For Windows and macOS, Gedit can be downloaded from the homepage.

Setup #

Gedit is configured in Preferences.

Line numbering

In the View section, select Display Line Numbers.

Indentation

In the Editor section, select:

  • Tab width: 4
  • Insert spaces instead of tabs
  • Enable automatic indentation

Syntax Highlighting

Syntax Highlighting works automatically, but the coloring method is selected based on the file extension - for example, .py for Python.

Therefore, as soon as you create a new file in this editor, you should save it under the correct name as soon as possible.

Indentation practice #

As already mentioned, in Python it is important how many spaces a line starts with. Therefore, it will be useful for us to know how to quickly indent blocks of text. Let's see how to do it.

Copy this text into the editor:

OPHELIA:
Good my lord,
How does your honour for this many a day?
HAMLET:
I humbly thank you; well, well, well.
OPHELIA:
My lord, I have remembrances of yours
That I have longed long to re-deliver.
I pray you, now receive them.
HAMLET:
No, not I.
I never gave you aught.
OPHELIA:
My honour’d lord, you know right well you did,
And with them words of so sweet breath compos’d
As made the things more rich; their perfume lost,
Take these again; for to the noble mind
Rich gifts wax poor when givers prove unkind.
There, my lord.

(An excerpt from Hamlet by W. Shakespeare)

This text is not very clear, so we will try to space it out to make it look like this:

OPHELIA:
    Good my lord,
    How does your honour for this many a day?
HAMLET:
    I humbly thank you; well, well, well.
OPHELIA:
    My lord, I have remembrances of yours
    That I have longed long to re-deliver.
    I pray you, now receive them.
HAMLET:
    No, not I.
    I never gave you aught.
OPHELIA:
    My honour’d lord, you know right well you did,
    And with them words of so sweet breath compos’d
    As made the things more rich; their perfume lost,
    Take these again; for to the noble mind
    Rich gifts wax poor when givers prove unkind.
    There, my lord.

To indent one line, set the cursor at the beginning of the line and press the Tab key. Each time you press it, the line will be indented by 4 spaces.

If you indent too much, you can reduce the indentation using Shift+Tab.

If you want to indent multiple lines at once, select them all and press Tab. You can also "unindent" the whole selection using Shift+Tab.

And that's it! Now you not only have the editor set up, but you also know how to use it.


Toto je stránka lekce z kurzu, který probíhá nebo proběhl naživo s instruktorem.