Setting Up VS Code: Extensions and Tips
Categories:
Extensions
Enhance your Ansible development experience in VS Code with these recommended extensions:
Linter
Linter by Nando Vieira. This extension supports linters for various languages, including YAML.
Trailing Spaces
Trailing Spaces by Shardul Mahadik. Visualizes trailing spaces by highlighting them in red. To configure this extension to automatically remove extra spaces when saving:
- Press Ctrl + Shift + P and select Preferences: Open User Settings.
- Search for
trailing spaces
. - Enable Trim on Save.
Markdown All in One
Markdown All in One by Yu Zhang. A comprehensive suite for writing Markdown, offering keyboard shortcuts, table of contents generation, auto-preview, and more.
Git Graph
Git Graph by mhutchie. View and manage your repository with a visual git graph. Easily perform Git actions such as cherry-picking directly from the graph.
Git Commit (No Verify)
Git commit(no verify)
by DevEscalus. Skip the pre-commit
hook and perform a “no-verify” commit. To
use this feature, enable it in settings after installation.
Note:
You can also perform a “no-verify” commit using the Git command line:
git commit --no-verify
Black Formatter
Black Formatter by Microsoft. Automatically formats Python code adhering to a standard style. Enable Black Formatter by adding the following to JSON User Settings:
"[python]": {
"editor.formatOnType": true,
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.formatOnSave": true
},
Tips
Multiple Cursor Selection
- Alt + Click: Create a new cursor at the click location.
- Ctrl + Alt + Up/Down: Add a new cursor above or below the current cursor.
- Ctrl + Shift + L: Create cursors at all occurrences of the selected text.
- Ctrl + Alt + Shift + I: Create cursors at the start of each line of the selected text.
- Ctrl + D: Select the next occurrence of selected text and create a cursor. Repeat to continue selecting further occurrences.
- Shift + Alt + Click: Add an additional cursor at the click location for simultaneous editing.
You can also use the command palette (Ctrl+Shift+P) and type “Create cursor” to explore more options. For Mac users, substitute Ctrl with Cmd in the shortcuts listed.
Fold / Unfold
- Ctrl + K followed by Ctrl + 0: Fold
- Ctrl + K followed by Ctrl + J: Unfold
Font Size Adjustment
Adjust font size with Ctrl + Shift + + and Ctrl + -.
Comment / Uncomment
Toggle comments with Ctrl + /.
Environment Variables
To run VS Code with specific local environment variables, create a .env
file
with your desired settings. Instruct VS Code to use this file by adding the
following line in .vscode/settings.json
:
{
"python.envFile": "${workspaceFolder}/.env"
}
Ensure that the .env
file is ignored by Git by including it in your .gitignore
:
.env
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.