Full Pycharm Tutorial (--PYCHARM) macro definition of editor function

Source: Internet
Author: User

1. Why Use macros

Join you need to repeat something many times, such as checking the source code and sending it to console debugging, can we simplify a series of operations into one step, or even use a set of shortcut keys instead?

2. Preparatory work

(1) The Pycharm version is 2.7 or higher.

(2) Consistent with the behavior in product documentation.

(3) Create a project and add at least two scripts to it, see Getting Started and Debugger

3. Record macro

Select the Edit→macros→start macro Recording command on the main menu, and the macro recording started prompt appears at the bottom of the window.

Open the script file that you want to execute (note the using Macros in the editor as described in the list limit), and then perform the corresponding demand action:

(1) Code in the Select all editor (e.g. press CTRL + A in the edit window)

(2) Right-click, select the Execute selection in console command from the popup shortcut menu

Then click the Edit→macros→stop Macro Recording command on the main menu, Pycharm will prompt you to save the macro for the current record. If HM is not specified at this point, Pycharm will set it as a temporary macro command, where we name the macro "Run in console":

Now, looking again at the Edit→macros menu, we'll find the macro command we just defined in the list:

4. Assign shortcut keys for macro commands

Next we specify a shortcut key combination for this macro command, as follows.

In the Settings dialog box, open the Keymap page, expand the Macros node, find our newly added macro command "Run in console", right click, select Add Keyboard shortcut in the Popup shortcut menu:

Next, specify the desired shortcut key combination in the Enter Keyboard Shoctrut Dialog dialog box. Note that at this point we can only click the controls in the dialog box with the mouse pointer, and any keyboard action is considered to be the setting of the shortcut key.

As you can see, the system does not prompt for related shortcut key conflicts, our settings are available, click Apply and Close the dialog box. The new shortcut keys are displayed in the menu:

5, the use of macro commands

Now we have completed a private order for a macro command. At this point we can run any open script file on the console. We can do this through the menu command Edit→macros→run in console, or through the shortcut key alt+r to achieve this function more quickly. Let's try it:

Open another script file in the editor, press Alt+r,ok, and the script is automatically loaded into the console and run:

Full Pycharm Tutorial (--PYCHARM) macro definition of editor function

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.