Search code examples
javascriptreactjsvisual-studio-codeshortcutexpand

Is there a quick way/ shortcut for expanding contents in brackets for VS code (Not collapsing/expanding methods)


So my teacher typed this code all in one line:

Alert.alert("Invalid Number!", "Number has to be a number between 1 and 99.", [{text: "OK", style: "destructive", onPress: resetInputHandler}]);

then pressed something to auto format it to this:

Alert.alert(\
"Invalid Number!",\
"Number has to be a number between 1 and 99.",\
[{text: "OK", style: "destructive", onPress: resetInputHandler}]\
);

where each content moved to its own line.


Solution

  • They probably use Prettier and its VS Code plugin which formats your code whenever you hit "Save" or activate the "Format Code" command.