'VSC: How to auto close curly brackets in f-strings
Hi I want to ask if it's possible to enable auto closing curly brackets in f-strings in Visual Studio Code. In Python you use often f-strings and therefore you need curly brackets.
print(f"Hello {name}!")
I already found something but I don't know if that feature is already implemented and if not if I can implement it with external plugins?: https://github.com/microsoft/vscode-python/issues/13673
Solution 1:[1]
VS Code has this auto closing brackets feature built-in in the editor. It's just disabled by default if you use it inside a string. To make it always close the brackets, Go to File > Preferences > Text Editor > Auto Closing Brackets
then change the value from 'languageDefined' to 'Always'. The Option.
Solution 2:[2]
Use the "Always" Auto Closing Brackets setting, but limit it to Python in your settings.json:
"[python]": {
"editor.autoClosingBrackets": "always"
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | SiJiL |