The most complete Pycharm tutorial (30) -- File Watchers in Pyhcarm

Source: Internet
Author: User

The most complete Pycharm tutorial (30) -- File Watchers in Pyhcarm

1. Subject

The usage of file watcher in PyCharm is described in detail.

2. Preparations

(1) The Pycharm version is 3.1 or later.

(2) The File Watchers plug-in is available. This plug-in should be installed by default when installing Pycharm (if not, you need to install it manually, see product documentation for details ):

(3) Familiarize yourself with the usage instructions in advance. For more information, see Using File Watchers.

(4) In this tutorial, We will process LESS and CoffeeScript files. We recommend that you do some preview work in advance.

3. Install the Node. js plug-in

First, download and install the Node. js plug-in. Open the Plugins page of IDE settings and search for the corresponding plug-ins:

After the installation is complete, restart Pycharm.

4. Install the LESS and CoffeeScript compilers.

There are two ways to install these two compilers:

(1) first, install it manually. Open local terminal (click the Terminal window button at the edge of the PyCharm window) and run the npm command to install LESS and CoffeeScript:

(2) second, use the Pycharm interface for installation: Click the setting button on the main toolbar, and click the green plus sign on the Node. js and NPM page:

In the Available Packages dialog box, select the library to be installed (select less here) and click Install Package:

After the installation is complete, the relevant compiler files will be written to the root directory of the project:

These files will be used later.

5. configure File Watchers

This step is automatically completed by Pycharm.

6. Configure the corresponding file watcher for the LESS file.

If no configuration is configured, the following error message is displayed when the LESS file is opened:

Click the Add watcher connection button. In the displayed dialog box, select the executable type of file watcher (select LESS here) and specify the generated format from the standard output:

In this configuration window, you can get a general idea of the actual functions of file watcher;

(1) monitor changes to all the LESS files in the project

(2) Use external extensions to compile files. Generally, useLessc. cmdCompiler.

7. Configure the corresponding file watcher for the CofeeScript file

If no configuration is configured, the following error message is displayed after the CofeeScript file is opened:

Click Add watcher connection. In the displayed dialog box, select the executable type of file watcher (CoffeeScript is selected here ):

In this configuration window, you can get a general idea of the actual functions of file watcher:

(1) tracking changes to all CoffeeScript files in the project.

(2) Use external extension. coffee to compile files in external extension. js, which are generally defined in the Program FieldCoffee. cmdCompiler.

(3) Use the external extension. coffee to compile the file in the external extension. map, which is usually defined in the Program field.Coffee. cmdCompiler.

8. edit file watcher.

Open the LESS file and make some changes, such as renaming the variable @ myColor to @ Color and changing its value. File watcher will immediately process the modified file and use the external. CssConvert it into an output file:

Next, open and edit the CoffeeScript file and make some modifications, such as changes.OppositeThe value of the variable. file watcher will generate a JavaScript file and a ing source file:

Note that PyCharm displays both the generated file and source file in the project window.

9. Is there a problem?

File Watcher fails to be executed. PyCharm will prompt you to help fix it:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.