Reputation: 6742
Is it possible to add spaces between imports and braces in WebStorm's auto-import feature?
Currently how the auto import looks like:
import {AbstractControl} from '@angular/forms';
I want to change it to:
import { AbstractControl } from '@angular/forms';
Upvotes: 126
Views: 36245
Reputation: 25165
While the other answers are correct, they are not portable.
You must remember to change IntelliJ settings on all machines you run the project.
There is a better alternative!
Add .editorconfig
file to your project.
On your specific request for "IntelliJ/WebStorm", such can be achieved by putting this on .editorconfig
:
ij_typescript_spaces_within_imports = true
You can read more on IntelliJ and specific .editorconfig
rules here.
To give you a better example of what an .editorconfig
file can do, check the following:
root = true [*] charset = utf-8 [*.{js,jsx,ts,tsx,vue}] indent_style = space indent_size = 2 end_of_line = lf insert_final_newline = true trim_trailing_whitespace = true ij_typescript_spaces_within_imports = true
Upvotes: 20
Reputation: 71
Update .editorconfig
, add properties for typescript and javascript files
[{*.ats,*.cts,*.mts,*.ts}]
ij_typescript_spaces_within_imports = true
[{*.cjs,*.js,*.jsx}]
ij_javascript_spaces_within_imports = true
Upvotes: 7
Reputation: 16
You might want to check the Within interpolation expressions
in the Other
section of the Spaces
tab.
Upvotes: 0
Reputation: 3254
Go to WebStorm > File > Settings > Editor > Code Style > JavaScript > Spaces (second tab), scroll to section "Within" and check ES6 import/export braces.
Go to WebStorm > File > Settings > Editor > Code Style > TypeScript > Spaces (second tab), scroll to section "Within" and check ES6 import/export braces.
Upvotes: 43
Reputation: 3594
Yes. Go to WebStorm -> Preferences -> Editor -> Code Style -> JavaScript -> Spaces (second tab), scroll to section "Within" and check ES6 import/export braces.
Upvotes: 275