Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make Webstorm "Reformatting Source Code" to change double quotes to single quotes?

When I push cmd + alt + l Webstorm doing some reformating to beautify my JavaScript sources. Ho to make Webstorm automatically change double quotes to single quotes in my sources?

like image 938
Vlad Ankudinov Avatar asked Mar 10 '16 14:03

Vlad Ankudinov


People also ask

How do you change double quotes into single quotes?

Use the String. replace() method to replace double with single quotes, e.g. const replaced = str. replace(/"/g, "'"); . The replace method will return a new string where all occurrences of double quotes are replaced with single quotes.

How do you replace a double quote in a string?

To remove double quotes just from the beginning and end of the String, we can use a more specific regular expression: String result = input. replaceAll("^\"|\"$", ""); After executing this example, occurrences of double quotes at the beginning or at end of the String will be replaced by empty strings.

How do you format a double quote?

If the quotation enclosed in single marks also contains material–whether another quotation or the title of a work–that needs to be set off with quotation marks, use double quotation marks around that material. The pattern is double, single, double quotation marks.


Video Answer


1 Answers

In Webstorm 2017.1, do the following:

  1. Go to File -> Settings | Preferences
  2. Choose Editor -> Code Style -> TypeScript
  3. Select 'Punctuation' tab
  4. Change: Use 'double' quotes to Use 'single' quotes. (Additionally, you can change 'in new code' to 'always')

Webstorm auto-import change to use double quotes instead of single quotes

like image 126
Eduardo Vazquez Avatar answered Sep 18 '22 20:09

Eduardo Vazquez