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

Talk Python's Mastodon Michael Kennedy's Mastodon