Why the module function in ES6 is first import and then from? Is there a smooth way to write?

< H2 > original question: < / H2 >

A module that uses ES6 in a smart editor (such as WebStorm) introduces a module, first import {} from "fs";
and then jump the cursor back to curly braces {} to write the desired module, because there is a smart prompt at this time.

is there any way to introduce the write module smoothly without jumping the cursor?

< hr >

add:

like ptyhon is from xxx import xxx , this design can avoid the problem of jumping cursor. The main purpose of asking this question is:

  1. Why did the International Standards Organization design the format import from
  2. in the first place?
  3. how to improve this problem

about how to improve this question , a solution has been found in WebStorm. Sf limits the time for questioners to answer, and will supplement the answer later.
you are welcome to add the solution in other editors and question 1 ;
Thank you.


< H2 > how to optimize the input mode of import module < / H2 >

in WebStorm

add a template to Live Templates , as shown below:

1

Type keywords in Abbreviation , Description is the description (optional), and fill in the code template in Template Text .

Template Text example, you can modify it by yourself

  

webstorm has a shortcut that is introduced automatically. For example, a component is < Abc >. If you write < Abc/ > directly in the js where you need to introduce the abc component, then tab,webstorm will help you automatically import, and from to the location of the component at the top level. It's still very convenient. I don't know if I'm talking to you about the same thing

.
Menu