Skip to content

Rpinski/vscode-shebang-snippets

Repository files navigation

Shebang Snippets

Visual Studio Marketplace Open VSX

Set of snippets for Visual Studio Code to insert "shebang" lines for various types of scripts and interpreters used on Unix-like systems.

Features

Shebang Snippets

After opening a new file you can just type # or press CTRL+SPACE at the beginning of the first line to add the full line:

Shebang Snippets in action

Currently supported shebang snippets:

  • Shell:
    • sh
    • bash
    • zsh
  • Expect: expect -f
  • Perl: perl
  • Lua: lua
  • Python:
    • python
    • python3
  • PHP: php
  • Node: node
  • F#: fsharpi --exec
  • Ruby: ruby
  • Groovy: groovy
  • PowerShell Core: pwsh

Magic Comments for Encoding

For some languages the magic comment for encoding

# -*- coding: utf-8 -*-

can be inserted by typing # at the beginning of the second line. The snippet offers different encodings for selection.

Complete magic comment for encoding

Encoding selection

Automatic Selection of Language Mode

After inserting a shebang snippet the extension automatically switches current editor tab to the appropriate language. For example, if you insert a shebang for the Python interpreter, the editor will switch to "Python" mode.

Language Mode selection

Language Mode in Status Bar