AppCode integrates with the Prettier code formatter. You can reformat selected code fragments as well as entire files or directories using the Reformat with Prettier action. AppCode adds this action as soon as you install Prettier as a dependency in your project or globally on your machine, Prettier is available in
Moreover, the key code style rules from the Prettier's configuration are applied to the AppCode Code Style settings. As a result, generated code (e.g. after refactoring or quick-fix) and the code that is already processed with Prettier are formatted consistently.
Before you start
Download and install Node.js.
Install and enable the Prettier repository plugin on the Plugins page as described in Installing, Updating and Uninstalling Repository Plugins and Enabling and Disabling Plugins.
To install Prettier
Open the embedded Terminal ( ) and type
npm install --save-dev --save-exact prettier or
npm install --global prettier at the command prompt. Learn more about installation modes from the Prettier Official website.
To configure Prettier in AppCode
- On the Prettier page, that opens, specify the path to the
prettierpackage and choose the Node.js interpreter to use. If you choose the
Projectalias, AppCode will automatically use the project default interpreter from the Node interpreter field on the Node.js and NPM page.
In most cases, AppCode detects the project default interpreter and fills in the field itself. You can also choose another configured local interpreter or click and configure a new one.