57

i'm trying to indent my code in visual studio code. I searched and i found that ctrl + F + K should be work, but it doesn't. I tried cmd + k + f too, but it still not working. I hope you can help me!

Steph8
  • 1,483
  • 2
  • 16
  • 32
  • Close, but it is not exactly cmd + k + f (not all 3 keys at the same time), see my answer below for the exact combination. – auspicious99 Jun 04 '20 at 10:11
  • In VS4Mac 2019, there are three shortcuts configurations: VS for Mac (native), VS for Windows and VS Code. It prompts to select one of three scheme right after the installation. That is why the answers below are different and confusing; as each one is covering different scheme, without specifying which one. VS for Mac's native shortcut to format document is mentioned in Tim Cuculic's answer: `Control + i`, but if you had VS for Windows scheme selected, it won't work (then I think the shortcut is `Control + Shift + F`). – vulcan raven Nov 25 '20 at 23:11
  • Thanks for pointing that out. It looks like the question is asking for VS Code, though. VS Code comes as a standalone product where there isn't a choice of shortcut configs to use. – auspicious99 Jun 03 '21 at 18:14

13 Answers13

56

The shortcut is: Alt + Shift + F

Ronan Boiteau
  • 9,608
  • 6
  • 34
  • 56
jsbisht
  • 9,079
  • 7
  • 50
  • 55
55

Updated December 21, 2017: as pointed out by Fabio, on mac it should be: + ]

On Windows: indent control is ctrl + ]

A good way to find commands is by navigating to: Code -> Preferences -> Keyboard Shortcuts

Also, the Visual Studio Code team provided those handy shortcut pdfs:

Another helpful command to achieve this might be: shift + option + f which is auto format.

seN
  • 1,045
  • 14
  • 21
35

The shortcut to format code on Visual Studio for Mac Community Edition is Ctrl + i

Tim Cuculic
  • 543
  • 5
  • 5
13

(edited on 4th Jan 2023: the answer below still remains the same, in version 1.74.2, Nov 2022)

For visual studio code version 1.36.1 (2019)

visual studio code version 1.36.1 (2019)

To auto-format the selection, use ⌘K ⌘F (the trick is that this is to be done in sequence, ⌘K first, followed by ⌘F).

auto-format selection or document

To just indent (shift right) without auto-formatting, i.e., blindly indent, use ⌘]

indent options

As indicated in Visual Studio Code's Keyboard Shortcuts (⌘K ⌘S, or from the menu as shown below)

keyboard shortcuts

auspicious99
  • 3,902
  • 1
  • 44
  • 58
12

The shortcut to align code in MAC is : Option/ALT + Shift + F.

Siddharth Sunchu
  • 866
  • 10
  • 13
8

Visual Studio for Mac Community Edition v 7.5.4 code format is: ^ I

Gregory
  • 101
  • 1
  • 2
5

The shortcut is:

Option Shift F
Max
  • 183
  • 1
  • 5
  • 18
4

Mac 16 M1 Pro

cmd + k + f working for me

sweetnandha cse
  • 705
  • 7
  • 16
4

cmd + A + cmd + K + cmd + F

this worked for me.

All I do is to hold "cmd" and then press A, K, and F one by one.

Himanshu Suthar
  • 437
  • 2
  • 9
  • 22
3

On Visual Studio for Mac Version 8.7

Select the code and go Edit -> Format -> Format Document Edit -> Format -> Format Document

panos.f
  • 54
  • 1
  • 4
1

Only Ctrl + I for me worked. Everything else hasn't worked.

Doug Silva
  • 11
  • 1
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 30 '22 at 03:11
0

Fix Formatting in Visual Studio for MAC 2019: Control + I Source here

0

You can always redefine the shortcut via the preferences > Keyboard Shortcuts: Mine was set to ^|, which did not work. So I changed it to shift + option + f (since this shortcut only printed Ï)

Hope this helps ;).