From the course: Visual Studio Code for Python Developers

The integrated terminal

From the course: Visual Studio Code for Python Developers

Start my 1-month free trial

The integrated terminal

- [Instructor] Let's talk a little more about the integrated terminal in VS Code because one of the really nice features of Visual Studio Code is that is has an integrated terminal. And having a terminal built into your editor is a great convenience because you don't have to change to another application window in order to execute terminal commands. To view the terminal, you can either select the terminal from here in the view menu or you can just type control+` and it's the same on both platforms. So I'll type control+` and on my English language keyboard here the back tick is located at the top left under the escape key. And it's on the same key as the tilda character but it might be different for you if you have a different keyboard. So I've brought up the terminal and the terminal runs with same permissions as the code app itself does. And the current directory for the terminal starts out in your projects working directory. You can open multiple terminals within the terminal panel. So you can see that in this dropdown right here I've only got one terminal open. But if I click this plus icon here, that will open a new one and now I can switch between terminals. I can also split the terminal into more views by choosing split terminal. So just choose split and you can see I've got two terminals now. To close the currently active terminal, you just click on the little trashcan icon and it goes away. So one cool feature of the integrated terminal is that you can select a piece of text in open editor and then execute it in the terminal using bash or shell commands. What I'm going to do is create a new file and I'll type in some text that I know works in the terminal so I'll write echo this is some text and I'll select it. And then to run it, I'll trigger the command pallette by typing command+shift+p and I'll type in run selected and you can see that as I type there is a command here called run selected text in active terminal. So I will choose that and you can see that it works. The text was echoed out to the terminal there. So you could, for example, use this feature to create a file that contains commonly used terminal commands and then just run them whenever you need them. The terminal also has some of its own key bindings so I'll go ahead and generate some content here by listing the directory a couple of times and to scroll up and scroll down you can use the page up and down keys and command+home and command+end also work. And if you right-click, you can see that I've also got some other commands. So to clear the terminal, you can type command+k or just choose the clear command right here. And to further customize the terminal, you can go into the settings view and search for terminal integrated. So what I'm going to do is I'm going to bring up the preferences and choose settings and let me go ahead and make this a little bit smaller and so I will search for terminal.integrated. Now you can see that I've the terminal option selected here and if I scroll down, you can see that there's a whole bunch of settings that I can choose. I can choose what kind of cursor to have, and what the current working directory should be and so on and so forth. I can choose the font family and the font size and so on and so forth. You know when I first starting using VS Code, I didn't make that much use of the integrated terminal but now I find myself using it all the time. Its a really great convenience and time saver.

Contents