Are you wondering how to shift YAML code to the left? This is probably one of the most useful commands I’ve ever learned when it comes to Home Assistant administration. Unfortunately, it never occurred to me to simply Google if there was an easier way to format an entire block of code.
Six months of heavy Home Assistant usage later, and I no longer have to manually delete a few extra spaces before each automation. I can’t tell you how exciting this is now. I used to dread copying and pasting automations from the community forum or other blog posts because of how labor intensive it was, or troubleshooting issues due to incorrect formatting.
So, how do you move an entire block of yaml text?
Move Block of Code to the Left (File Editor)
Just highlight the entire block of code (CTRL+A), and then press SHIFT+TAB. Voila! Your code has been moved over.
Move Block of YAML to the Right (File Editor)
Highlight the block of code (CTRL+A) and press “Tab” key or press space 4 times.
VSCode Shortcuts
Highlight the block of code and use CTL+ } to move to the right, or CTL+{ to move left.
Yes, this is a PSA and is worthy of an entire post. Hopefully you don’t waste as much time as I have!
Thanks! Short and helpful 🙂