Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to format/beautify Javascript in pycharm?

Tags:

pycharm

Pycharm's option + command + L to format HTML, or python files is very convenient, but doesn't seem to work for JS, is this an option?

like image 428
Stupid.Fat.Cat Avatar asked Oct 17 '16 21:10

Stupid.Fat.Cat


People also ask

Does Prettier format JavaScript?

Prettier is an opinionated code formatter with support for: JavaScript (including experimental features) JSX. Angular.

How can I get beautify code in PyCharm?

In the editor, select a code fragment you want to reformat. Before reformatting, you can take a look at the code style settings that are applied to the selected code: press Alt+Enter and click Adjust code style settings. From the main menu, select Code | Reformat Code or press Ctrl+Alt+L .

Is PyCharm good for JavaScript?

With PyCharm, you can develop modern web, mobile, and desktop applications with JavaScript and Node. js. PyCharm also supports React, Angular, Vue. js, and other frameworks and provides tight integration with various tools for web development.

Can you edit JavaScript in PyCharm?

Activate and configure Live Edit in JavaScript On the Live Edit page that opens, select the Update application in Chrome on changes in checkbox. By default, PyCharm shows on-the-fly preview only for HTML and CSS code. To enable Live Edit in JavaScript, select the JavaScript, HTML and CSS option.


2 Answers

This works to beautify js on windows in PyCharm Professional 2018.3:

  1. Ensure your cursor is active inside the js file you want to beautify.
  2. Alt + Ctrl + Shift + "L" to bring up the "Reformat File" popup
  3. Select "whole file" radio button and checkboxes for "Rearrange code" and "Code Cleanup"
like image 58
Bob Jordan Avatar answered Nov 15 '22 06:11

Bob Jordan


Yes it is (possible to format/beautify Javascript)!
The trick lies in TextMate Bundles. Below instructions are for Pycharm Community 2018.1.4

1) Go to the TextMate repo and look for the javascript tmbundle
2) Download the zip and unzip
3) In Pycharm, go to Settings -> Editor -> TextMate Bundles
4) Add new Bundle via the green + top right and select the javascript.tmbundle-master folder
5) If you get the same yellow box that says Some extensions declared in attached bundles are already used by native file types., then Show details -> Unregister native file type
6) Pycharm will then re-index, which may take a long time. After indexing is complete you should have javascript text highlighting.

enter image description here

Here is an arbitrary code sample

enter image description here

like image 23
Roman Avatar answered Nov 15 '22 06:11

Roman