Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>VS_for_McStasNew to Visual Studio Code? Get it now.
VS_for_McStas

VS_for_McStas

lomholy

|
90 installs
| (1) | Free
VS_for_McStas is an extension that aims to deliver McStas syntax highlighting, as well as GUI component insertion.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

VS-for-McStas README

VS-for-McStas is a VS Code extension for McStas .instr and .comp files. It provides syntax highlighting, a language server (hover and completion), a component browser and an auto formatter.

  • Syntax highlighting is on as soon as the extension is installed.
  • Language server: hover over a component type to see its parameters, and get completion for components, their parameters, DECLARE variables and instrument parameters. The server is written in Python and needs python3 (3.9 or newer) on PATH. On first use the extension installs it into its own virtual environment, so your Python and conda environments are left alone. If mcstas-language-server is already on PATH (for example from pipx), that one is used instead.
  • Component browser: press the neutron icon in the activity bar to see all McStas components by category. Clicking a component opens a form for its parameters, which generates the COMPONENT declaration or McStasScript code for you to copy into your instrument. The component data ships with the extension (currently from McCode v3.10.3), so no McStas installation is needed. Only "Open Component File", which opens the component's .comp source, needs McStas installed through conda. It searches the active environment and the usual conda install folders; to use a specific environment, pick it with the gear button in the Components view.
  • Formatter: format a file with Shift+Alt+F (Windows), Shift+Option+F (macOS) or Ctrl+Shift+I (Linux). It formats the C code in %{ %} blocks the same way as McCode's mccode-clangformat, with McCode's .clang-format style, and lays out component parameters. clang-format is installed together with the language server; set mcstas.formatter.clangFormatPath to use a different one. Formatting is not run on save.
  • Run, display and plot: the buttons in the component browser's title bar run mcrun, mcdisplay and mcplot in a terminal. If a conda environment is chosen with the gear button, they run in it (with conda, mamba or micromamba run); otherwise McStas must be available in that terminal.

In general, if you have any problems, desires for improvements etc. add an issue or your own fix on the Github Repository!

Other editors

The extension also runs in VSCodium, and the language server works outside VS Code. See installation.md for VSCodium, Neovim, Emacs, Helix, Sublime Text and JetBrains IDEs.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft