Locked learning resources

Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Locked learning resources

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Using Language Specific Settings

00:00 Now you might say it’s super nice to see the whitespace in Python files, but you may not want to see the whitespace in JSON files or README files and so on.

00:11 So VS Code has you covered on this one. And that’s actually one of the coolest features for the settings in my opinion, because you can set settings specifically for certain file types.

00:24 Currently on line six, you have the editor.renderWhitespace “all” setting enabled for all files. Go to the line before that, line five, hit Enter and start typing with quotes and square brackets the name of your favorite programming language.

00:43 In this case, I guess it’s Python, right? Once you hit Enter, you see that VS Code automatically sets a colon at the end and curly braces. And now any settings that you define inside these curly braces so that’s basically a new JSON object you’re creating there will only be applied to Python files.

01:07 To try this out, take the editor.renderWhitespace setting

01:12 and paste it inside the object that you defined with the Python and square bracket key.

01:21 And once you hit Save, you can see so that was maybe a little bit subtle. You can see that the JSON file doesn’t have the whitespace anymore. So when you’re zooming in, there aren’t any gray dots showing the indentation.

01:36 They are there when I select text in the JSON file, but they’re not there by default.

01:45 On the right side, where you can see the Python file, there are still the gray dots there. So that means the editor.renderWhitespace setting works, but it only works as you want it to work for Python files.

01:59 And this trick is quite handy because you can basically customize and curate your settings depending on different file types. So here we stay with the editor.renderWhitespace setting, but basically any settings that you can set in VS Code, you could set inside of Python or JSON or JavaScript or any other file type and you only adjust those settings inside the object for files of that file type.

02:28 So I think that’s pretty cool.

Become a Member to join the conversation.