Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>RISC-V AssemblyNew to Visual Studio Code? Get it now.
RISC-V Assembly

RISC-V Assembly

cwandel07

|
1 install
| (0) | Free
Formatting and syntax highlighting for RISC-V assembly
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

RISC-V Assembly

Formatting and syntax highlighting for RISC-V assembly (.s, .S, .asm).

Formatting

Run Format Document (Shift+Alt+F) or enable format-on-save (use riscv instead of riscv-asm if another extension owns your .s files):

"[riscv-asm]": {
  "editor.formatOnSave": true
},
"[riscv]": {
  "editor.formatOnSave": true
}

What it does:

  • one instruction per line, operands separated by ,
  • instructions indented one level after a label (directives stay at column 0)
  • trailing comments aligned at a fixed column
  • mnemonics normalized to a chosen case (optional)
  • blank line runs collapsed, trailing whitespace stripped
  • preprocessor lines (#include, #ifdef, ...) and block comments left untouched

Settings

All options live under riscvAsm.* in VS Code settings:

Setting Default Description
riscvAsm.indentSize 2 Spaces per indent level (ignored with tabs).
riscvAsm.useTabs false Indent with a tab instead of spaces.
riscvAsm.indentInstructions true Indent instructions after a label.
riscvAsm.mnemonicCase preserve preserve, lower or upper.
riscvAsm.alignComments true Align trailing comments at commentColumn.
riscvAsm.commentColumn 40 Column where trailing comments start.
riscvAsm.maxBlankLines 2 Max consecutive blank lines kept.

Project config

Commit a .riscvfmt.json to share formatting with your team. It is found by walking up from the file being formatted (stopping at the workspace root) and overrides the VS Code settings above — see .riscvfmt.example.json:

{
  "indentSize": 4,
  "mnemonicCase": "lower",
  "commentColumn": 48
}

Invalid JSON or invalid values produce a warning and fall back to the VS Code setting for that option.

Development

npm install
npm test        # compile + run the test suite

Press F5 in VS Code to launch an Extension Development Host.

Notes

  • .s/.S files are intentionally left to other RISC-V extensions (e.g. Venus) for syntax highlighting; the formatter works with both their riscv language id and this extension's riscv-asm. Only .asm files open as riscv-asm by default. If you want this extension's own highlighting instead, add "files.associations": { "*.s": "riscv-asm" }.
  • To publish: set a publisher in package.json, then npx @vscode/vsce package.
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft