pythonjsonvisual-studio-codesettings

Trouble setting up the VSCode Extention 'Prettify Symbols Mode' on Windows for Python


Trouble getting PSM set up in python

I am using:

I've added settings to customize symbol prettification in Python, but the settings seem to have no effect. I've tried reloading VSCode and double-checking my configuration, but the symbols do not change.

Can anyone help me identify what I might be missing?

Here is the relevant section of my settings.json file:

"prettifySymbolsMode.substitutions":
  [ {
    "language": "python",
    "substitutions": 
    [
      { "ugly": "\\s?\\*\\*\\s?2",    "pretty": "²",       "post": "\\b" },
      { "ugly": "\\s?\\*\\*\\s?3",    "pretty": "³",       "post": "\\b" },
      { "ugly": "\\*",                "pretty": "·",       "pre": "[^\\*]|^", "post": "\\s|$" },
      { "ugly": "<-",                 "pretty": "←" },
      { "ugly": "->",                 "pretty": "→" },
      { "ugly": ">=",                 "pretty": "≥",       "pre": "[^=\\-<>]|^", "post": "[^=\\-<>]|$" },
      { "ugly": "<=",                 "pretty": "≤",       "pre": "[^=\\-<>]|^", "post": "[^=\\-<>]|$" },
      { "ugly": "==",                 "pretty": "=",       "pre": "[^<>=!]|^", "post": "[^<>=]|$" },
      { "ugly": "!=",                 "pretty": "≠",       "pre": "[^<>=!]|^", "post": "[^<>=]|$" },
      { "ugly": "lambda",             "pretty": "λ",       "pre": "\\b", "post": "\\b" },
      { "ugly": "math.sqrt",          "pretty": "√",       "pre": "\\b", "post": "\\(" },\n
      { "ugly": "sum",                "pretty": "∑",       "pre": "\\b", "post": "\\(" },
      { "ugly": "f",                  "pretty": "ƒ",       "pre": "\\b", "post": "(\"|')" }
    ]
  }
],
"prettifySymbolsMode.adjustCursorMovement": true,
<rest of settings file>

If anything more is required to diagnose the problem, please ask :)

I tried re-installing the plugin, re-installing VSCode and even removed and re-wrote the entire section of the settings.json file which has the settings for the plugin


Solution

  • There is an error : \n

     "pre": "\\b", "post": "\\(" },\n
    

    There should be problems listed in your VS Code.

    I installed Prettify Symbols Mode -> Tested settings.json in workspace or User setting. Then saved file.

    Added >= , and there was no problem.

    enter image description here

    settings.json:

    {
        "prettifySymbolsMode.substitutions":
        [ {
          "language": "python",
          "substitutions": 
          [
            { "ugly": "\\s?\\*\\*\\s?2",    "pretty": "²",       "post": "\\b" },
            { "ugly": "\\s?\\*\\*\\s?3",    "pretty": "³",       "post": "\\b" },
            { "ugly": "\\*",                "pretty": "·",       "pre": "[^\\*]|^", "post": "\\s|$" },
            { "ugly": "<-",                 "pretty": "←" },
            { "ugly": "->",                 "pretty": "→" },
            { "ugly": ">=",                 "pretty": "≥",       "pre": "[^=\\-<>]|^", "post": "[^=\\-<>]|$" },
            { "ugly": "<=",                 "pretty": "≤",       "pre": "[^=\\-<>]|^", "post": "[^=\\-<>]|$" },
            { "ugly": "==",                 "pretty": "=",       "pre": "[^<>=!]|^", "post": "[^<>=]|$" },
            { "ugly": "!=",                 "pretty": "≠",       "pre": "[^<>=!]|^", "post": "[^<>=]|$" },
            { "ugly": "lambda",             "pretty": "λ",       "pre": "\\b", "post": "\\b" },
            { "ugly": "math.sqrt",          "pretty": "√",       "pre": "\\b", "post": "\\(" },
            { "ugly": "sum",                "pretty": "∑",       "pre": "\\b", "post": "\\(" },
            { "ugly": "f",                  "pretty": "ƒ",       "pre": "\\b", "post": "\"|'" }
          ]
        }
      ],
      "prettifySymbolsMode.adjustCursorMovement": true
    }