Pycharm用戶手冊:https://www.jetbrains.com/help/pycharm/quick-start-guide.html
editions comparison matrix
之前都用的vscode,初次接觸pycharm,以免費的社區版爲例,將用戶手冊中的一些內容搬運一些以便之後查閱
目錄
- key map
- Get started
- Step 1. Open/Create a project in PyCharm
- Open an existing project
- Check out an existing project from Version Control
- Create a project from scratch
- Creating a Python file
- Configure project interpreter
- Step 2. Look around
- Step 3. Customize your environment
- Step 4. Generate some code
- Step 5. Find your way through
- Step 6. Run, debug and test
- Step 9. Keep your source code under Version Control
- Configuring PyCharm settings
- Manage plugins
- Compare files
- File encoding
- Configure encoding for a directory or a file without built-in encoding information
- Change encoding of a single file that doesn't contain explicit encoding
- Change encoding of a project
- File and code templates
key map
Ctrl+Alt+T: quickly surrounding your code with complete constructs
Shift+F10: Run
Shift+F9: Debug
Ctrl+/: Comment and Uncomment Blocks of Code
Ctrl+點擊模塊名等: 查看源碼
Shift+Enter: 換行
Ctrl+Shift+ - : 將文件內的所有代碼塊全部摺疊
Ctrl+F: find and replace any fragment of code in the currently opened file
Ctrl+Shift+F: find and replace any fragment of code in the currently opened file
Alt+F7: full-scale search via Find Usages
Double Shift: Search Everywhere
Get started
Step 1. Open/Create a project in PyCharm
Open an existing project
It is also possible to drag an existing project directory or a separate file to the Welcome screen, and open it in PyCharm.
Check out an existing project from Version Control
Create a project from scratch
- 最上面的Location爲工程存放的地址
- New environment選項是創建一個新的虛擬環境,其中的Location爲新的虛擬環境的存放地址,Conda executable路徑選擇如圖所示
- Existing Interpreter中的Interpreter選擇anaconda安裝地址中的python解釋器
Creating a Python file
Configure project interpreter
When you configure a project Python interpreter, you need to specify the path to the Python executable in your system. You can create several project interpreters based on the same Python executable. This is helpful when you need to create different virtual environments for developing different types of applications.
創建完成之後使用命令行查看,確實新建了一個虛擬環境
Step 2. Look around
Terminal, Python console
可以看到在左下角有一個很小的圖標:
將鼠標懸浮在上面,可以看到可以開啓以下窗口:
其中就包括了Python終端以及默認激活了工程所用虛擬環境的命令行窗口:
TODO (to do)
雙擊即可回到上次寫的TODO位置
copy file path
Step 3. Customize your environment
Appearance
在這裏選擇Pycharm的顏色主題。這裏還是選擇護眼的黑色吧。
Editor
Code style
Step 4. Generate some code
consider quickly surrounding your code with complete constructs(Ctrl+Alt+T)
Step 5. Find your way through
Basic search
You can find and replace any fragment of code both in the currently opened file Ctrl+F, or in an entire project Ctrl+Shift+F.
Search for usages
To find where a particular symbol is used, PyCharm suggests full-scale search via Find Usages Alt+F7:
Project navigation
Search Everywhere
click the magnifying glass button in the upper right-hand corner of the window, or invoke it with Double Shift (press Shift twice).
Step 6. Run, debug and test
Run / Debug
Run: Shift+F10 Debug: Shift+F9
Run configuration
When you perform run, debug, or test operations with PyCharm, you always start a process based on one of the existing run/debug configurations, using its parameters.
When you run your application for the very first time, PyCharm automatically creates the temporary Run/Debug configuration. You can modify it to specify or alter the default parameters and save it as a permanent Run/Debug configuration.
For example, if you want to run some script before/after the build phase, you can do this easily by creating an external tool:
Step 9. Keep your source code under Version Control
VCS
PyCharm integrates with many popular version control systems: Git (or GitHub), Mercurial, Perforce (supported in Professional edition only), Subversion.
Local history
In addition to traditional version control, you can use the local history. With Local History, PyCharm automatically tracks changes you make to the source code, the results of refactoring, and so on
Local history is always enabled.
Configuring PyCharm settings
In PyCharm, you can configure the settings on two levels: the project level and globally.
Restore IDE settings
restore the defaults
restore your settings from backup
When you restore the default IDE settings, PyCharm backs up your configuration to a directory.
Manage plugins
因爲之前也沒用過Pycharm,先在網上隨便找了幾個聽說好用的插件試試看
參考地址:
https://blog.csdn.net/stormdony/article/details/90261391
https://zhuanlan.zhihu.com/p/98096152
Material Theme UI
Mongo Plugin
Markdown support
Markdown Navigator(Paid)
Key Promote X
Json Parser
Rainbow Brackets
.ignore
Compare files
Compare two files
- Select the files you want to compare in the Project tool window.
- From the context menu, choose Compare Files, or press Ctrl+D.
You can also select one file, choose Compare With from the context menu, and select a file that is outside your project.
Compare active editor with Clipboard
Right-click anywhere in the editor and choose Compare with Clipboard from the context menu.
Compare active editor with a project file
- Right-click the file you want to compare with the currently opened file in the Project tool window.
- Choose Compare File with Editor from the context menu.
File encoding
Configure encoding for a directory or a file without built-in encoding information
Change encoding of a single file that doesn’t contain explicit encoding
Change encoding of a project
File and code templates
這樣的話之後每次新建python文件時,這幾行就會出現在新文件的開頭