OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Why does VS Code sometimes colorise python print() as a magic method?

  • Thread starter Thread starter Michael Savage
  • Start date Start date
M

Michael Savage

Guest
I didn't like VS Codes existing colour scheme for syntax highlighting in python, so I added rules using the textmate scopes. For functions, I used "entity.name.function.python". However, sometimes, when printing a string, print is colorised the correct colour (e.g. green). However, when printing a class, it colorised print() different color. The textmate scope now says "support.function.builtin.python".

I tried to add a textMate scope for the "support.function.builtin.python", but is just shows up strikethrought, and isn't applied. Is there a way to have methods such as __init__() come up as one color, but print come up as the colour of normal functions, whatever it is printing

Here is a snippet from the settings.json:

Code:
{
                "scope":[
                    "entity.name.function",
                    "support.function.builtin.python"
                ],
                "settings": {
                    "foreground": "#97c516",

                },
                
            },
            {
                "scope":[
                    "support.function.magic.python"
                ],
                "settings": {
                    "foreground": "#5b7611",

                },
                
            },
<p>I didn't like VS Codes existing colour scheme for syntax highlighting in python, so I added rules using the textmate scopes. For functions, I used <code>"entity.name.function.python"</code>. However, sometimes, when printing a string, print is colorised the correct colour (e.g. green). However, when printing a class, it colorised <code>print()</code> different color. The textmate scope now says <code>"support.function.builtin.python"</code>.</p>
<p>I tried to add a textMate scope for the <code>"support.function.builtin.python"</code>, but is just shows up strikethrought, and isn't applied. Is there a way to have methods such as <code>__init__()</code> come up as one color, but print come up as the colour of normal functions, whatever it is printing</p>
<p>Here is a snippet from the settings.json:</p>
<pre><code>{
"scope":[
"entity.name.function",
"support.function.builtin.python"
],
"settings": {
"foreground": "#97c516",

},

},
{
"scope":[
"support.function.magic.python"
],
"settings": {
"foreground": "#5b7611",

},

},
</code></pre>
 

Latest posts

Top