Customizing Robot Framework Highlighting in VS Code
This guide shows how to change the font styles RobotCode uses for Robot Framework files in VS Code.
Editor Style
Section titled “Editor Style”RobotCode sets font styles for Robot Framework files, independently of your current theme: for example, test case and keyword names are bold and italic, section headers bold and underlined, and imports, embedded arguments, keyword calls inside the arguments of other keywords and documentation italic. You can change these styles or add colors.
How to Change the Styles
Section titled “How to Change the Styles”-
Open your VS Code user settings:
- Press Ctrl + Shift + P (Windows/Linux) or CMD + Shift + P (Mac)
- Type:
Preferences: Open User Settings (JSON)
-
Add the following code to your
settings.jsonfile. It contains RobotCode's default rules; change thefontStylevalues or add aforegroundcolor where you like.
Your textMateRules list replaces RobotCode's list, so keep the rules you don't change in it. The rules of editor.semanticTokenColorCustomizations are combined with RobotCode's rules, so there the rules you change are enough.
"editor.tokenColorCustomizations": { "textMateRules": [ { "scope": "comment.line.configuration.robotframework", "settings": { "fontStyle": "bold" } }, { "scope": "entity.name.function.keyword-call.inner.robotframework", "settings": { "fontStyle": "italic" } }, { "scope": "string.unquoted.embeddedArgument.robotframework", "settings": { "fontStyle": "italic" } }, { "scope": "entity.name.function.keyword-call.robotframework", "settings": {} }, { "scope": "entity.name.function.testcase.name.robotframework", "settings": { "fontStyle": "bold italic" } }, { "scope": "entity.name.function.keyword.name.robotframework", "settings": { "fontStyle": "bold italic" } }, { "scope": "variable.name.readwrite.robotframework", "settings": {} }, { "scope": "keyword.control.import.robotframework", "settings": { "fontStyle": "italic" } }, { "scope": "keyword.other.header.settings.robotframework", "settings": { "fontStyle": "bold underline" } }, { "scope": "keyword.other.header.variable.robotframework", "settings": { "fontStyle": "bold underline" } }, { "scope": "keyword.other.header.testcase.robotframework", "settings": { "fontStyle": "bold underline" } }, { "scope": "keyword.other.header.task.robotframework", "settings": { "fontStyle": "bold underline" } }, { "scope": "keyword.other.header.keyword.robotframework", "settings": { "fontStyle": "bold underline" } }, { "scope": "keyword.other.header.comment.robotframework", "settings": { "fontStyle": "bold italic underline" } }, { "scope": "string.unquoted.character.escape.robotframework", "settings": {} } ]},
"editor.semanticTokenColorCustomizations": { "rules": { "*.documentation:robotframework": { "italic": true //"foreground": "#aaaaaa" }, "*.embedded:robotframework": { "italic": true }, "*.builtin:robotframework": { "italic": true } }}Released under the Apache-2.0. Copyright © 2022-present Daniel Biehl