1

I recently started using Visual Studio Code, and I'm wondering if there is any command to automatically indent a selected section of code. I'm looking for something similar to the Re-Indent Current Line or Selection option in Netbeans. I tried using Reindent Selected Lines, but that isn't doing anything. Does anyone know how to do this? Thanks.

2
  • There is a shortcut to format a selection - look for it in your keyboard shortcuts. Ctrl-K Ctrl-F. Commented Sep 5, 2018 at 4:08
  • Hmm, that seems like what I'm looking for, thanks for the suggestion. Unfortunately, when I try to use it I just get the error message: "There is no selection formatter for 'haxe'-files installed." Commented Sep 5, 2018 at 4:56

1 Answer 1

2

'CTRL + K, CTRL + F' formats the current selection: https://blogs.msdn.microsoft.com/zainnab/2010/05/19/format-the-current-document-or-selection/

'SHIFT + ALT + F' formats the whole document including indents.

Sign up to request clarification or add additional context in comments.

3 Comments

That's a helpful command, thanks. It does help with indentation. Although, it also makes some changes to the formatting of my code that I don't like, so I would still like a command to format only certain lines, if it exists.
After having another look, you can format selection with CTRL + K, CTRL + F. Read more: blogs.msdn.microsoft.com/zainnab/2010/05/19/… - will update answer
Someone suggested that in a comment on my original post too. When I try to use that key combination I just get the error message: "There is no selection formatter for 'haxe'-files installed." Still, it's looking to me like the first shortcut you suggested is the closest thing VSCode has to what I'm looking for. Thanks a bunch.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.