This Visual Studio Code extension will lint common unicode substitutions when code is copied from various sources such web pages and document editors. Some substitutions such as using an En Dash instead of a Hyphen will pass language linting and then fail to execute.
Lints the below Unicode substitutions by default:
Character Name | Character | Unicode | Replace with | Character | Replace with Unicode |
---|---|---|---|---|---|
En Dash | – | 2013 | Hyphen | - | 002D |
Em Dash | — | 2014 | Hyphen | - | 002D |
Horizontal Bar | ― | 2015 | Hyphen | - | 002D |
Start Single Quote | ‘ | 2018 | Single Quote | ' | 0027 |
End Single Quote | ’ | 2019 | Single Quote | ' | 0027 |
Start Double Quote | “ | 201C | Double Quote | " | 0022 |
End Double Quote | ” | 201D | Double Quote | " | 0022 |
Low Double Quote | „ | 201E | Double Quote | " | 0022 |
High Double Quote | ‟ | 201F | Double Quote | " | 0022 |
Slightly smiling face | 🙂 | D83D DE42 | Colon & parentheses | :) | 003A 0029 |
Smiling face with smiling eyes | 😊 | D83D DE0A | Colon & parentheses | :) | 003A 0029 |
Format Document (Alt + Shift + F) is supported for all languages.
With the 1.33 release of Visual Studio Code multiple document formatters are supported. These cannot be run synchronously but must be triggered separately using Format Document with.
Linting rules can be added in the user and workspace settings.
For instructions on how to write your own rules read: Custom Rules
The default linting rules can be disabled so that you can use your own rules only instead of merging the two.
"unicodesubsitutions.enableDefaultRules": false,
Auto document formatting can be disabled to prevent automatic changes to your document.
"unicodesubsitutions.enableFormatting": false
-
Open Extensions (Control + Shift + X)
-
Search for "Unicode-Substitutions"