Nauč se Python > Kurzy > Beginners course PyLadies > Installation > Editor installation > Kate

Instalace Kate

Linux installation:

Fedora
$ sudo dnf install kate
Ubuntu
$ sudo apt-get install kate

For Windows and macOS you can probably download Kate from its webpage.

Settings

Line numbers

In menu View pick Show Line Numbers.

Indentation:

In Settings choose Configure Kate

Editing > Indentation

Now set here:

  • Default indentation mode: Python
  • Indent using: Spaces
  • Tab Width: 4
  • Indentation width: 4
  • Backspace key in leading blank space unindents
Colours:

Colouring of code is automatic if you save the file with proper extension – e. g. .py for Python.

So it's better if you save your file as early as possible.

Indentation practice

As we already mentioned it's important in Python by how much spaces is line indented. So we will have to learn to quickly indent block of text.

First of all copy following text into your 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 composed
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.

Hamlet, W. Shakespeare

This text is not well-arranged so we will indent it like that:

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 composed
    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 you coursor in the beginning of the line and press Tab. With every press you will indent the like by 4 spaces.

If you indent too much, press Shift+Tab.

If you would want to indent more lines just highlight them and press Tab. For undo press Shift+Tab.


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