Skip to content

Instantly share code, notes, and snippets.

@JeOam
Last active August 22, 2022 18:31
Show Gist options
  • Save JeOam/3044f7e0d371478813ce to your computer and use it in GitHub Desktop.
Save JeOam/3044f7e0d371478813ce to your computer and use it in GitHub Desktop.
PyCharm Tips
Keyboard Shortcuts Descption
Cmd-/ Comment/uncomment
Cmd + Alt + L Reformat code
Cmd-F Find text
Cmd-Shift-F Find text in files
Cmd-Plus Expand code block
Cmd-Minus Collapse code block
Cmd-B Goto declaration of current variable
Cmd-U Goto superclass
Cmd-Opt-Left Go back to where you were
Cmd-Opt-Right Go forward to where you were
Shift,Shift Search everywhere
Cmd + Shift + NumPad+ Expand all
Cmd + Shift + NumPad- Collapse all

via Mac PyCharm keyboard shortcuts, PyCharm Default Keymap PyCharm Default Keymap

@JeOam
Copy link
Author

JeOam commented Jul 3, 2015

Live Templates 功能的使用:

Preferences => Editor => Live Templates => Click +, Choose "Live Templates".

Edit, eg:

Abbreviation: bp
Description: Add a breakpoint programmatically
Template Text:
    import pytest
    pytest.set_trace()
Applicable in Python

Save, and type "bp", and press [Tab].


Use ipdb as Python debugger:

Abbreviation: bp
Description: Add a breakpoint programmatically
Template Text:
    import ipdb
    ipdb.set_trace()
Applicable in Python
pip install ipdb

@Piwero
Copy link

Piwero commented Jun 28, 2022

the "Template Text" can be improved in one line by adding

Template Text:
__import__('ipdb').set_trace(context=21)
Applicable in Python

where context is the number of lines you want to show when reaching the breakpoint

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment