Reputation: 1199
Just wondering if there is a shortcut or extension in visual studio code to surround a code block - or more specifically highlight the widget name and then surround that widgets children.
Often is the case where I have created, lets say a:
Padding(
padding: EdgeInsets.all(10.0),
child: Container(
...
But then after some writing, i want to surround that Padding
with something else, like a Column
or Row
.
As is, I need to prefix the Padding
with Row( child:
and then scroll down and add the new ),` bracket
Is there not a way to just select the Padding
and then tell vs code that I am going to prefix this so add the bracket for me?
Pretty sure I have seen this in action in IntelliJ
Upvotes: 110
Views: 80820
Reputation: 31
Ctrl + dot on windows or Command + dot on mac should do the trick!
Upvotes: 3
Reputation: 358
I have been installed a plugin "key promoter X", and it offers you shortcuts on actions you do in IDE. Then you are wrapping once via context menu, and it offers you a shortcut, set or manage, and I have adde "cmd + W" to wrap with a widget. Very useful.
Upvotes: 0
Reputation: 461
Simply press:
Ctrl + dot
on windows
or
Command + dot
on mac
and a list pops up showing wrapping options!
Upvotes: 6
Reputation: 1175
In Ubuntu VSCode it is also ctrl + . where as in Ubuntu Android Studio or Intellij it was alt + enter.
Upvotes: 0
Reputation: 583
⚠️ If wrap with Column
is not shown on Right-click - refactor:
Then Right-click > wrap with Column
Here is the reason why this happen: https://dartcode.org/docs/refactorings-and-code-fixes/ . Also documented there: you can now bind shortcuts to the refactor actions:
Ctrl
+.
in Code opens the “lightbulb” menu showing all code fixes/refactors. Code v1.20 gained the ability to keybind quickfixes. To do this you should edit your keybindings.json file and include the ID of the refactor as found below.
Upvotes: 46
Reputation: 541
On VS Code on Windows just right-click on any widget and press "Refactor" or use the keyboard shortcut
Ctrl+Shift+R
Upvotes: 22
Reputation: 9593
Place your cursor in the widget you want to edit and use CTRL + .
shortcut to see the options. Use CMD + .
for MacOS. That will do it.
Upvotes: 111
Reputation: 4120
If any one looking for Android Studio its option + return
in Mac and Alt + Enter
in Windows.
Upvotes: 6
Reputation: 243
Right click on the widget and choose 'refactor', then 'wrap with new widget'
Upvotes: 3
Reputation: 277747
Sure!
Vscode offer a few refactor options, including Wrap with Column
:
Just right-click on a widget and press "Refactor".
Upvotes: 248