Nauč se Python > Materiály > Snake Workshop for PyLadies > Preparation > Editor installation > Visual Studio Code

Installation of Visual Studio Code #

Download and installation #

You can download the editor from its homepage. Choose the green Download button and select the installer for your system. Then follow the installer instructions as with any other program.

Sending telemetry data #

Visual Studio Code can send data about your usage (including the contents of files you have open) to Microsoft. If you do not wish to send this data, you can turn this off.

Open File > Preferences > Settings (macOS: Code > Preferences > Settings). Find telemetry.enableTelemetry and uncheck this entry.

Also see the official guide for this.

Setup #

Everything else is already installed. It's time to start programming!

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.