Modern Python Projects Transcripts
Chapter: Your code editor
Lecture: Plugins

Login or purchase this course to watch this video and the rest of the course contents.
0:00 In a nutshell. VSCcode is just text editor So to.
0:03 Turn it into a proper code editor.
0:06 You'll have to install some extensions.
0:08 Right now we only have the python extension and Jupiter one that comes preinstalled with python
0:13 If python is not the only language that you work with,
0:17 you can also install plugins for other languages.
0:19 One way to do this is to go back to this welcome page that we see
0:23 when we opened VSCode. And here you can select some of the most popular
0:27 plugins, for example for JavaScript,
0:29 Java, PHP and stuff like that.
0:31 Apart from language specific plugins,
0:33 they're also framework specific plugins.
0:36 For example, if you're a python developer,
0:38 maybe you're working with Django or Flask,
0:40 Web framework and VSCode has plugins for those two.
0:43 So, let's search for Django. If we extend this panel,
0:48 you can see how many downloads each extension has.
0:51 So usually when you Install extension and there are multiple ones,
0:54 select the one with the most downloads.
0:56 This Django plugin will provide you with some additional features related to Django.
1:01 For example, you will get the syntax highlighting for Django specific files that this HTML
1:05 files with template tags. You will also get some additional snippets that you can use
1:10 and so on. So, let's actually try to install it,
1:14 and I'm going to show you what I mean.
1:16 So now let's say we're working with Django html file, as you can see VSCode figure
1:24 out that this is a Django html file.
1:26 But if for some reason you want to change how the VSCode is interpreting this
1:31 file, you can click here, or you can select change language mode.
1:36 This is very useful. For example,
1:38 when you have a file saved as html,
1:41 but it's full of markdown code and you actually want VSCode to treat this
1:45 file as Markdown file. So, let's see what we have for HTML.
1:49 Right now we have the standard HTML file and Django html.
1:53 If we treat this file as a standard HTML file,
1:56 we get no auto completion for the template tags from Django.
2:01 You can see there is nothing, if we treated us.
2:04 Django HTML. Now we have all those snippets that can make writing your Django
2:11 code easier, next plugin that I want to show you.
2:16 It's not specific to Python, but it's very useful for any programming language.
2:20 It's called IntelliCode and what it does.
2:23 It tries to predict which term from the auto completion least you are most likely to
2:28 use, in a given situation. And it will put that auto completion suggestions at the
2:33 top, with this star. Behind the scenes,
2:36 Microsoft has used some machine learning to analyze millions of lines of code,
2:40 and they try to predict in which situation which auto completion terms should be the most
2:46 suitable. So, I really like this extension because it works surprisingly well.
2:52 Next, we have a plugin that can help you a bit with writing documentation.
2:56 It's called autodocstring, and when you install it,
2:59 you can type those three double quote signs and then press enter,
3:03 and this will generate the scaffolding for your documentation.
3:06 So, for example, when a function already contains some arguments,
3:10 it will copy and paste those arguments inside the documentation.
3:14 Let's actually give it a try.
3:15 Let me open some file. Let's remove all that and let's say I want to
3:22 write another greeter. You can see we have auto completion to generate the docstring
3:29 I press enter, and now we can quickly write a summary, press stop, here
3:38 We can specify the type, description of this argument,
3:46 and we are done. Another plugin that It's not specific,
3:49 to python, but it's very useful when you're working on a very large cold base
3:53 It's called bookmarks. So here again,
3:55 I have the source code of the Django Web framework,
3:58 and let's go and install this plugin.
4:05 With this plugin, you can put bookmarks in your code.
4:07 So, for example, when you're new to a project and there is a lot
4:10 of code and you don't really know, what's going on,
4:13 I really like to use this plugin to,
4:15 Make it easier to understand, how different things work.
4:19 So, for example, if I'm looking into some tests and I want to see
4:23 what they test, I might put some bookmarks in the test.
4:25 I might then dig deeper into some specific functions,
4:29 put bookmarks there and so on.
4:31 So, let's try to put a few bookmarks here and there.
4:34 As you can see, they are marked in the gutter,
4:39 and now we have the whole menu related to bookmarks, where we can jump to the
4:45 previous and next bookmark, list all of them.
4:48 So, here is jump to the next one.
4:50 Well, this file only have one bookmark.
4:52 So, let's put another one. Here is how we can quickly jump between bookmarks in
5:00 the same file. Of course,
5:02 It's much easier to use given shortcuts for that we can least all bookmarks from all
5:07 the files, and you can quickly jump between them.
5:10 So, as I said, this is a very useful plugging when you want to
5:13 jump around a large code base.
5:15 And speaking of large code base and collaborating with others,
5:18 VSCOde has a source control tab.
5:21 But a much more useful extension that you can use is called Git lens.
5:27 This is one of the biggest extensions, I have seen for VSCode,
5:30 and it's really packed with features.
5:33 So, when you install it, you can,
5:34 for example, show blame annotations,
5:36 per specific line, pedophile in the status bar or in the Hover.
5:41 Now you can see this comes from the git lens.
5:44 We can see who was the last person, to change the specific function,
5:48 and you have a massive amount off different options that you can do.
5:52 You can open file in GitHub.
5:54 You can compare it with the head.
5:56 You can copy the commit message.
5:58 Moreover, you even have a new sidebar menu related to git lens.
6:05 And of course, you have some additional command palette options.
6:12 So check out the git lens documentation because this is a very massive plugin,
6:15 and I don't think I'm using more than,
6:18 like 10 or 20% off what it can do.
6:21 And finally, I have three small extensions that can make your life a bit easier
6:25 First one is indent-rainbow,
6:28 So in python we're not using brackets.
6:30 And sometimes if you have a code of this nested by multiple levels off indentation,
6:36 it's hard to figure out where one function or one loop ends.
6:39 Another one starts so we can install indent rainbow,
6:43 and then each level of indentation will have a different color,
6:47 so it will be easier for you to see where a specific function ends.
6:53 And sometimes you might notice that when you're copying some code,
6:56 let's say from stack overflow or from a different program,
7:00 and you paste it into VSCode.
7:02 It's not correctly indented, so you have to heat up a couple of times.
7:06 If you find this annoying, check out the Paste and indent plugin.
7:11 It will add a new command that you have to actually assigned to a keyboard shortcut
7:14 and this command will paste code from your clipboard and try to indent correctly.
7:20 And actually, in most cases it does indented correctly,
7:23 so you no longer have to press tab.
7:28 And finally, this is a completely personal preference.
7:30 But I really like the extension called Error lens,
7:34 because I like to see the errors and warnings next to the code,
7:37 not at the bottom of the VSCode or in a separate tab.
7:41 So with this extension, you can configure how the warnings and errors are displayed.
7:45 You can, for example, display an icon in the gutter and the whole text
7:50 of a warning or in error next to the code.
7:52 So those are, in my opinion,
7:54 the most important plugins to make writing python code in VSCode much easier
7:59 But those are not all the plug ins that I use.
8:02 So if you want to learn about some other plugins that I can recommend,
8:06 I have a blog post about them,
8:08 so you can go check it out.
8:10 And here I have some screenshots and also descriptions.
8:14 Some of the plugins I just covered.
8:16 And there are some others that I didn't,
8:18 so maybe you'll find it interesting.