pycharm commonly used shortcut keys + pycharm commonly used settings

pycharm commonly used shortcut keys
 


1, editing (Editing)

Ctrl + Space basic code completion (classes, methods, attributes)
Ctrl + Alt + Space to quickly import any type
Ctrl + Shift + Enter to complete the sentence
Ctrl + P parameter information (called method parameter)
Ctrl + Q to quickly view documents

F1 external document

Shift + F1 external documents into web documents Home

Ctrl + Shift + Z -> Redo Redo

Ctrl + Mouse Introduction / entering the custom code
Ctrl + F1 error description or warnings
Alt + Insert automatically generate code
Ctrl + O again method
Ctrl + Alt + T selected
Ctrl + / line comment / cancellations line comments
Ctrl + Shift + / block comment
Ctrl + W to increase the selected block
Ctrl + Shift + W back to the state before
Ctrl + Shift +] / [selected block end, began
Alt + Enter Quick Fix
Ctrl + Alt + L code formatting
Ctrl + Alt + O optimization introducing
Ctrl + Alt + I Auto indent
Tab / Shift + Tab indent, the current line is not indented
Ctrl + block X / Shift + Delete the current line or to the selected clipboard
Ctrl + C / Ctrl + Insert copy the current line or a selected block to the clipboard
Ctrl + V / Shift + Insert pasting from the clipboard
Ctrl + Shift + V paste from the latest buffer
Ctrl + D Copies the selected region or row
Ctrl + Y delete selected line
Ctrl + Shift + J to add intelligent line
Smart Wire Ctrl + Enter
Shift + Enter another line
Ctrl + Shift + U between selected areas or blocks of code switching
Ctrl + Delete To delete the character to the end of the
Ctrl + Backspace Delete character to begin
Ctrl + Numpad +/- Expand / collapsing code block (the current position: a function, comments, etc.)
the Ctrl + Shift + Numpad +/- expand / Collapse all code blocks
Ctrl + F4 running off tab
 2, find / replace (Search / replace)
F3 to a
Shift + F3 before a
Ctrl + R replace
Ctrl + shift + F or 2 consecutive tapping global shift lookup {find what a string throughout the project, such as the look is how to use this function before watching a string function name}
Ctrl + Shift + R global substitution
 3, operation (running)
the Alt + Shift + F10 operating mode configuration
Alt + Shift + F9 debug mode configuration
Shift + F10 run
Shift + F9 debugging
Ctrl + Shift + F10 run editor configured
Ctrl + Alt + R run manage.py task
 4, commissioning (Debugging)
F8 to skip
F7 to enter
Shift + F8 Exit
Alt + F9 to run the cursor
Alt + F8 validation expression
Ctrl + Alt + F8 to quickly validate the expression
F9 recovery program
Ctrl + F8 break switch
Ctrl + Shift + F8 View breakpoint
 5, navigation (navigation)
Ctrl + N Jump to kind
Ctrl + Shift + N to jump symbol
Alt + Right / Left jump to the next, a former editor of the tab
F12 back to the previous tool window
Esc from tool window back to the editing window
Shift + Esc to hide running window recently run
Ctrl + Shift + F4 to close the active tab to run
Ctrl + G to view the current line number, word, symbol
Ctrl + E eject the current file, open recently used files list
Ctrl + Alt + Left / Right Back, forward
Ctrl + Shift + Backspace to navigate to the nearest editing area
Alt + F1 to find or identify the current file
Ctrl + B / Ctrl + Click Go to declaration
Ctrl + Alt + B Jump to achieve
Ctrl + Shift + I see quickly define
Ctrl + Shift + B Jump to a type declaration
Ctrl + U method to jump to the parent, the parent class
Alt + Up / Down to jump onto a lower a method of
Ctrl +] / [jump to the end of the block, begin
Ctrl + F12 up the file structure
Ctrl + H type hierarchy
Ctrl + Shift + H method hierarchy
Ctrl + Alt + H calling hierarchy
F2 / Shift + F2 at a before a highlighted error
F4 / Ctrl + Enter editing resources, see resources
Alt + Home show navigation bar switch F11 bookmark
Ctrl + Shift + F11 bookmark mnemonic switch
Ctrl + # [0-9] Jump to identify bookmarks
Shift + F11 show bookmarks
 6, search-related (usage Search)
Alt + F7 / Ctrl + F7 query file usage
Ctrl + Shift + F7 file usage highlight the
Ctrl + Alt + F7 to display usage
 7, reconstruction (refactoring)
F5 copy F6 cut
Alt + delete Safely Remove
Shift + F6 rename
Ctrl + F6 to change the signature
Ctrl + Alt + N inline
Ctrl + Alt + M extraction method
Ctrl + Alt + V extract attribute
Ctrl + Alt + F extraction field
Ctrl + Alt + C extraction constants
Ctrl + Alt + P extraction parameters
 8, controls the VCS / the Local History
ctrl + K submitted project
Ctrl + T to update project
Alt + Shift + C to see recent changes
Alt + BackQuote ( ') VCS rapid pop-
 9, the template (Live templates)
Ctrl + Alt + J current line using a template
Ctrl + J inserted into the template
 10, basic (General)
the Alt + # [0-9] to open a respective tool window
Ctrl + Alt + Y synchronization
Ctrl + Shift + F12 maximize edit switch
Alt + Shift + F Add to favorite
Alt + Shift + I check the current configuration in accordance with file
Ctrl + BackQuote ( ') to quickly switch the current program
Ctrl + Alt + S to open the settings page
Ctrl + Shift + a to find all the action editor
Ctrl + tab to switch between windows

 

pycharm commonly used settings

lz reminder, set in pycharm can import and export, file> export settings can save the current pycharm in a jar file, reload can directly import settings> jar file, do not repeat the configuration.

 

file -> Setting ->Editor

1. Set the automatic introduction Python package, first in> general> autoimport -> python: show popup

     Shortcut: Alt + Enter: automatically add the package
2. "code completion" set the time delay

  > Code Completion   -> Auto code completion in (ms):0  -> Autopopup in (ms):500

3. Pycharm default font size can not be changed by the Ctrl + wheel, can be set in Mouse>

4. Display "line numbers" and "blank character"

  > Appearance  -> 勾选“Show line numbers”、“Show whitespaces”、“Show method separators”

5. Set Editor "Colors and Fonts" theme

  > Colors & Fonts -> Scheme name -> 选择"monokai"“Darcula”

  Description: First select "monokai", then "Save As" to "monokai-pipi", because the default theme is "read-only", some of the color of the font size of what can not be modified, a copy may be amended after!

  Change font size

> Colors & Fonts -> Font -> Size -> is set to "14"

6. operator to set the indent tab "Tab"

  File -> Default Settings -> Code Style

  -> General -> 勾选“Use tab character”

  -> Python -> check "Use tab character"

  -> Other language codes empathy settings

7. remove the default folding
  > Code Folding -> Collapse by default -> Check all removed

8. pycharm default saved automatically, according to their own habits ctrl + s may be set as follows:
    > General -> Synchronization -> ON Frame Deactivation and the Save Files Save files automatically if application is idle for .. sec to remove the hook
    > Editor tabs -> Mark modified tabs with asterisk tick

9.>file and code template>python scripts

#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
__title__ = '$Package_name'
__author__ = '$USER'
__mtime__ = '$DATE'
# code is far away from bugs with the god animal protecting
    I love animals. They taste delicious.
              ┏┓      ┏┓
            ┏┛┻━━━┛┻┓
            ┃      ☃      ┃
            ┃  ┳┛  ┗┳  ┃
            ┃      ┻      ┃
            ┗━┓      ┏━┛
                ┃      ┗━━━┓
                ┃  神兽保佑    ┣┓
                ┃ 永无BUG!   ┏┛
                ┗┓┓┏━┳┓┏┛
                  ┃┫┫  ┃┫┫
                  ┗┻┛  ┗┻┛
"""

10 python file default encoding

File Encodings> IDE Encoding: UTF-8;Project Encoding: UTF-8;

11. Code finishing setting

Here line breaks removed √, otherwise the bar, and baz will be separated on different lines, it does not look good.

 

File -> Settings -> appearance

1. Modify the IDE scheme shortcuts

  > Keymap

1) execute selection in console : add keymap > ctrl + enter

  The system comes with several shortcuts programs, drop-down box like "defaul", "Visual Studio", is very useful in finding Bug, "NetBeans 6.5", "Default for GNOME" and so on options,

  Because "Eclipse" program more popular, but also more personal, and ultimately chose the "Eclipse". 

  There are a few common shortcuts do not like Eclipse, in order to modify the program must first copy of Eclipse: 

  (1) Code prompts, by default [Ctrl + Space], was replaced like Eclipse, that is, [Alt + /]

  Main menu -> code -> Completion -> Basic -> set to "Alt + /"

  Main menu -> code -> Completion -> SmartType -> 设置为“Alt+Shift+/”

  But "Alt + /" default again 

  Main menu -> code -> Completion -> Basic -> Cyclic Expand Word occupied, first delete it say it (right-click Delete)!

  (2) Close the current document, the default is [Ctrl + F4], was replaced like Eclipse, that is [Ctrl + W]

  Main menu -> Window -> Active Tool Window -> Close Active Tab -> 设置为 “Ctrl+F4”;

  Main menu -> Window -> Editor -> Close -> set to "Ctrl + W";
2. Set IDE skin theme

 

 > Theme -> 选择“Alloy.IDEA Theme”

  Or setting the search theme may change the subject, all unified color change

File > settings > build.excution

Automatically execute code every time you turn python console

> Console> pyconsole

SYS Import
# Print ( 'the Python% S% S ON'% (The sys.version, sys.platform))
sys.path.extend ([WORKING_DIR_AND_PYTHON_PATHS])
Import OS
Print ( 'Current workdirectory:', The os.getcwd ())
AS NP numpy Import
Import SciPy AS SP
Import matplotlib MPL AS
If ipython installed, the more powerful the ipython in pyconsole

> console

选中use ipython if available

So every time you open pyconsole will open ipython

Note: ipython mounted in the virtualenv: (ubuntu_env) pika: / media / pika / files / mine / python_workspace / ubuntu_env $ pip install ipython

 

File > settings > Languages & Frameworks

 

Will automatically become open if the django support in the project settings, open the python console open django console, of course, if you do not want to turn off support for the project of django:

If you open the console will support multi-displays a django console in settings> build.excution>:

Django console settings are as follows

 

import sys
print('Python %s on %s' % (sys.version, sys.platform))
import django
print('Django %s' % django.get_version())
sys.path.extend([WORKING_DIR_AND_PYTHON_PATHS])
if 'setup' in dir(django): django.setup()
import django_manage_shell; django_manage_shell.run(PROJECT_ROOT)
 

File > settings > Project : initial project

project dependencies> LDA> project depends on these projects> select sim_cluster can call sim_cluster package in the LDA

 

pycharm environment and path configurations
python interpreter path
python interpreter program path
for python project execution path configuration python

For example, some items are running a system environment python2.7; some 3.4; some projects using virtualenv the python environment [python virtual environment configuration - pycharm in the project configuration]

In pycharm> file> settings> project: pythonworkspace> project interpreter> to select a corresponding item> project interpreter interpreter specified python

Run pycharm in configuration has an option to add content roots to pythonpath

After selecting a plurality sys.path will project the project path / media / pika / files / mine / python_workspace, which directory was used as a package, so that the package can not python by introducing the directory from SocialNetworks.SocialNetworks files.

However, preferably used sys.path.append (os.path.join (os.path.split (os.path.realpath (__ file __)) [0], "../ ..")) to add, so pycharm outside you can also run without error.

 

conduct python package management pycharm in
pycharm in the project can be included in package, directory (the directory name can have spaces), etc.

A certain py file in the package directory to call a function in another py file, first of all to directory to source root, in order from the first package first introduced correctly function, or how to introduce all wrong:

SystemError: Parent module '' not loaded, cannot perform relative import

Note: Directory> Right> make directory as> source root

python script interpreter path
when ctrl + shift + f10 / f10 python script execution

Cwd current working directory for the run / debug configurations in the working directory

May be disposed in the edit configurations> project or defaults in

console execution path and the current working directory
python console in execution

cwd为File > settings > build.excution > console > pyconsole中的working directory

And where you can configure

pycharm configuration os.environ environment
pycharm os.environ not be read in the terminal in the system environment variables

pycharm .bashrc parameters can not be read in os.environ

Use pycharm, or the use of dict os.environ returned are not provided in ~ / .bashrc is variable in terms of the module python console, but / etc / profile configuration variables. However, the use of the terminal in the python, os.environ but it can acquire the content ~ / .bashrc of.

Solution 1:

 

System environment settings in ~ / .bashrc can only run Spark program is available only in terminal shell, as .bashrc is only read for interactive shells.

If the current user is valid for the entire system (including pycharm like IDE), you should be in the system environment variable ~ / .profile file. If the whole system is set up for all users, modify / etc / profile or / etc / environment now.

As SPARK_HOME settings [Spark: errors related summary]

Solution 2: set in code, so that regardless of the environment there is no problem

 

# spark environment settings
import sys, os
os.environ['SPARK_HOME'] = conf.get(SECTION, 'SPARK_HOME')
sys.path.append(os.path.join(conf.get(SECTION, 'SPARK_HOME'), 'python'))
os.environ["PYSPARK_PYTHON"] = conf.get(SECTION, 'PYSPARK_PYTHON')
os.environ['SPARK_LOCAL_IP'] = conf.get(SECTION, 'SPARK_LOCAL_IP')
os.environ['JAVA_HOME'] = conf.get(SECTION, 'JAVA_HOME')
os.environ['PYTHONPATH'] = '$SPARK_HOME/python/lib/py4j-0.10.3-src.zip:$PYTHONPATH'
pycharm配置第三方库代码自动提示
 

Pycharm expand practical function
pycharm cleared compiled .pyc intermediate file
to select your workspace> Right> clean python compiled files

 

You can also write your own cleanup code

pycharm set up an external tool
[python Gadgets] pyc delete all files for the current pycharm py file opened in the corresponding directory. If it is run directly (instead of running the following tools in), then delete the E: \ pyc file in the mine \ python_workspace \ WebSite directory.

The above code is changed to delete external tool
PyCharm> settings> tools> external tools > + Add

Name: DelPyc

program: $ PyInterpreterDirectory $ / python Python installation path

Parameters: $ProjectFileDir$/Oth/Utility/DelPyc.py $FileDir$

Work directory: $FileDir$

Note: $ FileDir $ parameters behind Parameters is to say, DelPyc is delete all the files for the current pyc pycharm py file opened in the corresponding directory.

Then be directly executed by the following


Note: add a Tools named DelPycIn

program: Python installation path, eg D: \ python3.4.2 \ python.exe

Parameters: E:\mine\python_workspace\Utility\DelPyc.py

Work directory using the variable $ FileDir $

There are no parameters $ FileDir $, so you can delete commonly used directories r'E: \ mine \ python_workspace \ WebSite ', the two together with a more convenient

Code quality
when you are typing, PyCharm will check your code meets PEP8. It will let you know if you have too many spaces or blank lines, and so on. If you wish, you can configure PyCharm pylint run as an external tool.

python2 turn python3 fastest way to
/ usr / bin / 2to3 -wn $ FileDir $

This opens the pycharm in a file, right-py2 all external tools> py2topy3 can instantly current file directory into py3, is not very witty!

Original: https: //blog.csdn.net/ghr5582/article/details/80693591 
 

Guess you like

Origin blog.csdn.net/ths512/article/details/90316563