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.
- There is a shortcut to format a selection - look for it in your keyboard shortcuts. Ctrl-K Ctrl-F.Mark– Mark2018-09-05 04:08:06 +00:00Commented 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."CharType– CharType2018-09-05 04:56:40 +00:00Commented Sep 5, 2018 at 4:56
Add a comment |
1 Answer
'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.
3 Comments
CharType
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.
Zak Avery
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
CharType
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.