How do you get the python colour scheme while using sage on VS code?
Asked Answered
S

2

5

Currently, I name my files as .py while working on them, and then change them to .sage when I need to execute. Is there a way to get the python colour scheme for sage files on VS code?

There is an extension called SAGE enterprise management that claims to do it, but the instructions are a bit unclear:

It says:

Create a x3-code named folder inside your ~/.vscode/extensions/; Copy all files in yours recent created folder; Reload VS Code and enjoy;

I tried both copying my sage files into the folder, and the contents of the x3-extension into the folder, both of which didn't work.

Soluble answered 26/5, 2019 at 23:23 Comment(0)
C
4

The instructions referred to in the question are for Sage the accounting software, not for SageMath the Sage mathematics software system.

In the case of SageMath, we need to tell VS Code to apply Python formatting not only to files ending in .py, but also to files ending in .sage. One way to do that is to use the "file to language association" setting:

One would add associations from "*.sage" to "python".

This related question has answers explaining where Visual Studio Code's language extension files are located on macOS and Windows:

Contrapuntal answered 27/5, 2019 at 10:33 Comment(1)
I think it should be noted that this is done in settings.json. For me, on Windows 10, the file was located at C:\Users\<user name>\AppData\Roaming\Code\User. If using the settings window inside the editor instead (as in @qwyster's answer) - drop the quotation marks.Crafty
B
5

Following the first link provided in the prior answer, I got it worked. In details, go to Settings, type "files.associations" in the search box for Search settings.

It shows you a list of (item, value) in which you can add a new item (*.sage, python). See my screenshot below

enter image description here

Hope it works for you!

Bergren answered 23/9, 2020 at 14:32 Comment(0)
C
4

The instructions referred to in the question are for Sage the accounting software, not for SageMath the Sage mathematics software system.

In the case of SageMath, we need to tell VS Code to apply Python formatting not only to files ending in .py, but also to files ending in .sage. One way to do that is to use the "file to language association" setting:

One would add associations from "*.sage" to "python".

This related question has answers explaining where Visual Studio Code's language extension files are located on macOS and Windows:

Contrapuntal answered 27/5, 2019 at 10:33 Comment(1)
I think it should be noted that this is done in settings.json. For me, on Windows 10, the file was located at C:\Users\<user name>\AppData\Roaming\Code\User. If using the settings window inside the editor instead (as in @qwyster's answer) - drop the quotation marks.Crafty

© 2022 - 2024 — McMap. All rights reserved.