mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 02:58:56 +01:00
Support auto-closing quotes in Python raw string literals, etc
Python uses a ["string prefix"](https://docs.python.org/3/reference/lexical_analysis.html#string-and-bytes-literals) to denote bytes literals (`b''`), raw strings (`r''`), and formatted string literals (`f''`). This change makes it so that when one types `r'` in VS Code, the string will be auto-closed as `r''` (as an example). Python also supports multiple string prefixes for a single literal. I've tested that typing `fr'` will auto-close to `fr''`, and so forth.
This commit is contained in:
@@ -13,7 +13,23 @@
|
||||
{ "open": "[", "close": "]" },
|
||||
{ "open": "(", "close": ")" },
|
||||
{ "open": "\"", "close": "\"", "notIn": ["string"] },
|
||||
{ "open": "'", "close": "'", "notIn": ["string", "comment"] }
|
||||
{ "open": "r\"", "close": "\"", "notIn": ["string", "comment"] },
|
||||
{ "open": "R\"", "close": "\"", "notIn": ["string", "comment"] },
|
||||
{ "open": "u\"", "close": "\"", "notIn": ["string", "comment"] },
|
||||
{ "open": "U\"", "close": "\"", "notIn": ["string", "comment"] },
|
||||
{ "open": "f\"", "close": "\"", "notIn": ["string", "comment"] },
|
||||
{ "open": "F\"", "close": "\"", "notIn": ["string", "comment"] },
|
||||
{ "open": "b\"", "close": "\"", "notIn": ["string", "comment"] },
|
||||
{ "open": "B\"", "close": "\"", "notIn": ["string", "comment"] },
|
||||
{ "open": "'", "close": "'", "notIn": ["string", "comment"] },
|
||||
{ "open": "r'", "close": "'", "notIn": ["string", "comment"] },
|
||||
{ "open": "R'", "close": "'", "notIn": ["string", "comment"] },
|
||||
{ "open": "u'", "close": "'", "notIn": ["string", "comment"] },
|
||||
{ "open": "U'", "close": "'", "notIn": ["string", "comment"] },
|
||||
{ "open": "f'", "close": "'", "notIn": ["string", "comment"] },
|
||||
{ "open": "F'", "close": "'", "notIn": ["string", "comment"] },
|
||||
{ "open": "b'", "close": "'", "notIn": ["string", "comment"] },
|
||||
{ "open": "B'", "close": "'", "notIn": ["string", "comment"] }
|
||||
],
|
||||
"surroundingPairs": [
|
||||
["{", "}"],
|
||||
@@ -25,4 +41,4 @@
|
||||
"folding": {
|
||||
"offSide": true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user