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?
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
IN VS CODE i get the error "include file not found in browse. path."
with an error squiggle under my header file #include <stdio.h>
how can i make this library accessible to my code.
all i have is a folder and a main.c file
Very new to all this, the other answers seem to be out of my depth as im not sure what files they're accessing.
Thank you in advance.
Very similar problem to the one posed here, and thankfully a very similar solution.
Ctrl-Shift-P will open the "command bar", start trying C/Cpp: Edit Configurations until it's the top result then hit enter, this will create a c_cpp_properties.json file in the .vscode folder of your current project directory (making this configuration unique to this project, so you'll need to repeat this for other projects). This json file has sections for Mac, Linux and Win32, edit the section relevant to you or all if you know the paths for the other platforms. Each block has a name, includePath, defines, intelliSenseMode and browse property. The browse property has a child array called path (which is what we're looking for, include file not found in *browse.path*), add the paths to your include directories here, one string each, and remember to use forward slashes even if Windows gives you them as backward slashes.
While the offending error disappeared when adding the correct path to browse.path, I also added it to the includePath section because according to the hover tooltip includePath is used by the intellisense engine whereas browse.path is used by the tag parser. Can't hurt to have both set up correctly.
Attaching example of .vscode\c_cpp_properties.json file with browse.path which solved my issues with Arduino dependencies
{
"configurations": [
{
"name": "Win32",
"includePath": [
"C:\\Users\\localuser\\Documents\\Arduino\\libraries\\AzureIoTProtocol_MQTT\\src\\**",
"C:\\Users\\localuser\\Documents\\Arduino\\libraries\\AzureIoTUtility\\src\\**",
"C:\\Users\\localuser\\Documents\\Arduino\\libraries\\AzureIoTHub\\src\\**",
"C:\\Users\\localuser\\Documents\\Arduino\\libraries\\WiFiManager\\**",
"C:\\Users\\localuser\\Documents\\Arduino\\libraries\\ArduinoJson\\**",
"C:\\Users\\localuser\\AppData\\Local\\Arduino15\\packages\\esp8266\\tools\\**",
"C:\\Users\\localuser\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\2.4.2\\**",""
],
"forcedInclude": [],
"browse": {
"path":[
"C:\\Users\\localuser\\Documents\\Arduino\\libraries\\AzureIoTProtocol_MQTT\\src\\**",
"C:\\Users\\localuser\\Documents\\Arduino\\libraries\\AzureIoTUtility\\src\\**",
"C:\\Users\\localuser\\Documents\\Arduino\\libraries\\AzureIoTHub\\src\\**",
"C:\\Users\\localuser\\Documents\\Arduino\\libraries\\WiFiManager\\**",
"C:\\Users\\localuser\\Documents\\Arduino\\libraries\\ArduinoJson\\**",
"C:\\Users\\localuser\\AppData\\Local\\Arduino15\\packages\\esp8266\\tools\\**",
"C:\\Users\\localuser\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\2.4.2\\**"]
},
"intelliSenseMode": "msvc-x64",
"compilerPath": "C:\\WinAVR-20100110\\bin\\avr-gcc.exe",
"cStandard": "c11",
"cppStandard": "c++17"
}
],
"version": 4
}
All you need to have is, to check if browse.path exists in the c_cpp_properties.json file. If not include this part. It should fix the issue.
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "gnu11",
"cppStandard": "gnu++14",
"intelliSenseMode": "gcc-x64",
"browse": {
"path": ["${workspaceFolder}"],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
}
}
],
"version": 4 }
Hi i'm new into vscode and when i run a program there is some text that i want to get rid of.
i mainly want to remove the first two paragraphs, but also removing the path would be ideal
i tried code runner but thats not the solution i'm looking for
i also tried changing the color to black but i reckon there is a way to remove it
Adding the "-NoLogo" start parameter will remove the paragraph of text; If you open your settings file (Ctrl+Shift+P and then type "Settings" -> User Settings JSON), you can use the following bit of configuration:
// should go in the main JSON object with the other keys
"terminal.integrated.profiles.windows": {
// it might generate some more profiles automatically, but powershell is what matters
"PowerShell": {
"source": "PowerShell",
"icon": "terminal-powershell",
"args": ["-NoLogo"]
}
}
I believe by default those lines will always appear because those are the one that show up when you open cmd on Windows.
Also, by default, the path open to the current project folder, that the reason why you see the path.
You can do a cls to clear the terminal, but the path will remain unless you change the directory.
You can read more about VS Code integrated terminal here and about terminal profiles here
First go to terminal settings and then the add -nologo arg
I want to change the color of imported modules
Text Example
I understand I should edit the settings.json file like so: Settings Example
But I don't see any key for "module" or "package"
What do? Thanks!
You can try adding the following code to your setting.json:
"editor.semanticTokenColorCustomizations": {
"rules": {
"module:python": "#ff0000",
}
}
At the same time, the document also explains more detailed settings.
I was watching Corey Schafer's video on YouTube on 'Setting up a Python Developer Environment in sublime Text'.
I installed the anaconda package, but for some reason, the gutter marks (for linting) are not showing in the line number column.
I have not altered the default settings.
I have added Corey's user settings to the sublime-anaconda user settings file:
{
"auto_formatting": true,
"autoformat_ignore":
[
],
"pep8_ignore":
[
"E501"
],
"anaconda_linter_underlines": false,
"anaconda_gutter_marks": true,
"anaconda_linter_mark_style": "none",
"display_signatures": false,
"disable_anaconda_completion": true,
"python_interpreter": "/usr/local/bin/python3"
}
I should note that I have also tried adding:
"anaconda_gutter_marks": true,
to no avail.
I have also saved the settings and restarted sublime text.
You need to change your "python_interpreter" setting to the actual path of the python.exe executable on your system. Opening cmd and entering which python may be helpful in finding it. Once you've found it, change and \ characters to / - for example, C:\Python38\python.exe would become C:/Python38/python.exe.
Where you've copied the code from correy's GitHub there is a line called "python_interpreter": "/usr/local/bin/python3" just delete that line and restart sublime and the errors should be showing again.
Check the screenshot:
I use VS code since a while with some Extensions.
All is perfect expect when I use Flask.
Prettier put all flask code glued together, and intellisence is not working with flask code:
{% extends "layout.html" %} {% block style %} body {color: red; } {% endblock %}
{% block body %} you must provide a name {% endblock %}
What can I do to make it work with flask (trie flask-snippets)?
I run it in virtuel env (run before lauch vscode).
Thanks in advance,
I also had a similar problem and this is what I did to fix it :
Install the Better Jinja plugin. (https://marketplace.visualstudio.com/items?itemName=samuelcolvin.jinjahtml)
This will allow you to change the file association from plain "HTML" to "jinja-html" (it's on the lower right part of my vscode screen), and this will stop jinja codes from sticking to one another on save.
At this stage your intellisense will not work anymore, causing a lot of annoyance, so :
Go to preferences >> settings >> type "file associations" in the search settings bar, click on "edit settings.json"
Finally add the following line to the settings.json file :
"emmet.includeLanguages": {"jinja-html": "html"},
Restart your vscode. Every time you open an html file with jinja templating codes, as long as jinja-html is selected (not HTML!), prettify won't mess it up, and your intellisense should be working just fine. :)
add this like the screenshot below
"files.associations": {
"*.html": "jinja-html"
},
[screenshot]
Ok, so I tried the solutions from Ataua and Moby J, but wasn't able to get them to work. Maybe because I'm using Prettier globally.
Here's what worked for me:
There's a project called Unibeautify that seems kind of like a "one ring to rule them all" for tying together personalized settings across different formatters and filetypes.
It has a VS Code extension, VSCode-Unibeautify.
After installing the extension, you need to create a config file and tell VS Code where to find it. You can create and customize your own config if you want to use it for multiple languages, but here's what worked for me for Jinja:
# unibeautifyrc.yaml
HTML:
beautifiers:
- JS-Beautify
- Pretty Diff
and then, in your vscode settings:
// settings.json
"unibeautify.defaultConfig": "/PATH/TO/unibeautifyrc.yaml",
"unibeautify.enabled": true,
"[jinja-html]": {
"editor.defaultFormatter": "Glavin001.unibeautify-vscode",
"editor.formatOnSave": true
},
What I've done also, is to associate html files with the Jinja filetype in my project's settings.json. This helps if you just want to limit the use of Unibeautify to just Jinja files on a project by project basis. I think you could also make the below *.html more specific to your templates directory if you prefer.
// MYPROJECT/.vscode/settings.json
{
"files.associations": {
"*.html": "jinja-html"
}
}
This solution is powered by JS-Beautify which seems to work well with Jinja and powers Atoms atom-beautify extension, also by the same author of Unibeautify, Glavin001, a beautiful individual.
I have tried everything but at last, it worked for me.
Install the Better Jinja plugin.
Install the django plugin
Then go to settings by pressing ctrl+,, and search for file associations and goto settings.json and edit the following:
"files.associations": { "*.html": "jinja-html" },
"emmet.includeLanguages": {"jinja-html": "html"},
The aforementioned solutions did not quite work for me. I either lost highlighting, autocompletion or autoformatting.
I finally found a solution that gave me all of that:
Install "Better Jinja" or "Django" (better syntax highlighting within double quotes) plugin
Install "djLint" plugin
Press CTRL + Shift + P and type open settings json + Enter
This is my config and it works great for my jinja templates. djLint has more filetype-specific options to offer (see extension-description in VS Code).
// settings.json
"emmet.includeLanguages": {
"jinja2": "html",
"jinja-html": "html",
"django-html": "html",
},
"[jinja]": {
"editor.defaultFormatter": "monosans.djlint",
"editor.detectIndentation": false,
"editor.tabSize": 2,
"editor.formatOnSave": true,
},
"[jinja-html]": {
"editor.defaultFormatter": "monosans.djlint",
"editor.detectIndentation": false,
"editor.tabSize": 2,
"editor.formatOnSave": true,
},
"[django-html]": {
"editor.defaultFormatter": "monosans.djlint",
"editor.detectIndentation": false,
"editor.tabSize": 2,
"editor.formatOnPaste": true,
},
My jinja-templates use the extension .jinja2. To make it work with the "Django" plugin I add this to my settings:
// settings.json
"files.associations": {
"*.jinja2": "django-html"
},
The only complaint I have now is that I can't get the linked editing of tags to work :-D
The answer from Mobi J helped me but I think it was icomplete.
What did solve the same issue I was having was to add those two lines at the very ending of settings.json (before the last closing bracket):
"emmet.includeLanguages": { "jinja-html": "html" },
"editor.defaultFormatter": "vscode.emmet"
I actually did so by navigating Settings (Ctrl + , on Linux), but the result is just that addition to the settings.json file.
After that change, both intellisense and emmet are working, in .html and in .jinja files.