VS Code Extensions and Tips

Learn how to setup VS Code including recommended VS Code extensions for Ansible engineering tasks.

Extensions

Linter

Linter  by Nando Vieira. This extensions supports linters for several languages including YAML.

Trailing Spaces

Trailing Spaces  by Shardul Mahadik. Visualizes “trailing spaces” by making them red. Configure this extension to automatically removed “extra” spaces every time you press save with the following steps:

  1. Cntrl Shift p en selecteer Preferences: Open User Settings.
  2. Filter on trailing spaces.
  3. Enable Trim on Save.

Markdown All in One

Markdown All in One  by Yu Zhang, all you need to write Markdown (keyboard shortcuts, table of contents, auto preview and more).

Git Graph

Git Graph  by mhutchie. View a Git Graph of your repository, and easily perform Git actions from the graph e.g. for “cherry picking”.

Git commit (no verify)

Git commit(no verify)  by DevEscalus. Allows you to skip the pre-commit hook and perform a “no-verify” commit. After installation you first have to enable this option via settings.

Black Formatter

Black Formatter  by Microsoft. Opinionated formatter for Python code that can automatically format your Python code. Enable via JSON User Settings as follows:

    "[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 location of your click.
  • Ctrl + Alt + Up/Down: Create a new cursor above or below the current cursor.
  • Ctrl + Shift + L: Create multiple cursors at all occurrences of the current selected text.
  • Ctrl + Alt + Shift + I: Create multiple cursors at the beginning of each line of the selected text.
  • Ctrl + D: Select the next occurrence of the current selected text and create a cursor. Repeat to continue selecting next occurrences.
  • Shift + Alt + Click: Add another cursor at the location of your click, allowing you to edit multiple places at once.

You can also use the command palette (Ctrl+Shift+P) and type “Create cursor” to see all the options available. Please note that the above shortcuts are based on Windows and Linux, If you are using Mac, please use cmd instead of ctrl

Fold / Unfold

  • Ctrl + K Ctrl + 0: Fold
  • Ctrl + K Ctrl + J: Unfold

Font size

Cntrl Shift + and Cntrl -.

Comment / uncomment

Cntrl \



Last modified December 9, 2024: how-to vs code C2-633 (86bdca6)