Nix IDE tips and tricks (VS Code)

Wanted to create a post for sharing tips and tricks when using the ‘Nix IDE’ VSCode extension.

Please share any useful pointers that have increased your coding efficiency in .nix files and flakes in general.

I have added one keyboard shortcut below. Does anyone else have more? E.g. Is there any way to run nixos-rebuild or home-manager switch commands within the IDE?

Ctrl + Alt + L - reformat code lines so indent levels are all in line.
requires nix package nixpkgs-fmt and VSCode extension IntelliJ IDEA Keybindings

1 Like

This is awesome, I needed this!

You could even set it so that it reformats the code on every save.

1 Like

Yep, that’s how I have it. Maybe it’s even enabled by default

so i realised i cannot edit my OP to append new commands. Is there any functionality on discourse to create a continuously update-able post for stuff like this? anyway any useful command is:

Ctrl + Shift + ` - open terminal in the current VScode root folder. useful for running nixos-rebuild, flake updates and other commands.