Render lambda keyword as the greek symbol in VSCode?

Viewed 204

I want vscode to render lambda as λ in my editor. I do not want it to replace the word with the symbol, as that will just break my code since Python doesn't interpet λ as a keyword. It needs to purely be a rendering change, with the actual code still being lambda.

Are there any extensions that do this? Is it possible within the VSCode environment to do this?

1 Answers

The extension Prettify Symbols Mode allows you to do this. You'll have to edit your settings.json to specify this particular subsitution. To do this install the extension then go to the extension's settings page -> "Prettify Symbols Mode: Substitutions" -> edit in settings.json. Then add this:

"prettifySymbolsMode.substitutions": [
        {
            "language": "python",
            "substitutions": [
                {
                    "ugly": "lambda",
                    "pretty": "λ"
                },
            ]
        }
    ]

to the file.

There are more complete options and details available on the extension's page, and here is a more complete example of a Python config (with a lambda expression).

Related