Next, I will give you some introductions on how to build Python IDE Based on Sublime Text. I hope the article will help you.
1. Problem
When I recently used Sublime Text 2 to write Python code, I found two minor issues:
If functions such as img are used in the Code for interaction, when Ctrl + B is directly used for compilation, the interaction information cannot be entered in the running information column, and an error is reported.
Under Win 8.1, when Ctrl + B is used for compilation, the compilation information is not displayed in the running information column, and it is blank (this does not know whether it is a case, setting an error or a bug)
2. installed plug-ins
SublimeREPL
For the above two problems, I found the SublimeREPL plug-in, which can be used to run and debug some programs that require interaction, and work normally under Win 7 and Win 8.1.
The great thing is that this plug-in supports multiple languages, while Python also supports multiple running modes. I usually use Python and Python-RUN current file.
SublimeCodeIntel
SublimeCodeIntel supports code auto-completion, member/method prompts, and other functions. After this plug-in is installed, Sublime Text 2 will feel a bit like IDE.
SublimeLinter
SublimeLinter is used to check the code when writing code. It can check whether the Python code meets the requirements of PEP8.
3. Optimization
SublimeREPL add shortcuts
After SublimeREPL is installed, there is no shortcut key. You must click the toolbar with the mouse to run the program each time. It is a bit uncomfortable, so you need to add the shortcut key to SublimeREPL.
Here we can see the names and IDs of all Python methods. Based on this, you can customize user shortcut keys and enter them in preference-Key Binding-user:
| The Code is as follows: |
Copy code |
|
[{"Keys": ["f5"],
"Caption": "SublimeREPL: Python-RUN current file ",
"Command": "run_existing_window_command", "args ":
{
"Id": "repl_python_run ",
"File": "config/Python/Main. sublime-menu"
}}
] |
This article only defines the shortcut key for Python-RUN current file. I am using F5 here and can make flexible adjustments as needed.
Code area and compilation area are separated and displayed
Select View -- layout -- line: 2, split Sublime into the upper and lower parts, and select F5 for code compilation. The compilation information is displayed in the following compilation area.
We recommend several necessary common plug-ins below:
1. Tag plug-in
The Tag plug-in can provide html and css labels for web developers, which is convenient and convenient for web Front-end designers.
2. Prefixr plug-in
Provide some prefixes for css3, such
3. Terminal plug-in
The Terminal plug-in allows you to open the cmd command window in Sublime Text2. It is a practical plug-in. After the plug-in is installed, the shortcut key for opening the cmd command window is
Ctrl + Shift + T.
4. SublimeTmpl plug-in
This plug-in allows users to define file templates. For example, when writing an html file, the introduction information of repeated file headers is cumbersome. You can define a template to directly generate required information, for specific SublimeTmpl plug-in usage, Baidu.
5. SideBarEnhancements plug-in
A plug-in that enhances the browsing function of the sidebar folder.
6. DocBlockr plug-in
The plug-in used to generate the comment block. After installation, enter "/*" and press enter to generate the code comment block.
7. SublimeCodeIntel plug-in
Smart tip plug-in, this plug-in smart tip function is very powerful, you can customize the content library prompts, my Python smart prompt settings (configuration file path for packagesSublimeCodeIntel-master.codeintelconfig) is:
| The Code is as follows: |
Copy code |
{
"Python ":{
"Python": 'd:/Program Files/Python26/python.exe ',
"PythonExtraPaths": ['d:/Program Files/python26', 'd:/Program Files/Python26/DLLs ', 'd:/Program Files/Python26/Lib ', 'd:/Program Files/Python26/Lib/plat-win ', 'd:/Program Files/Python26/Lib/lib-tk', 'd: /Program Files/Python26/Lib/site-packages ']
}
} |
Among them, "pythonExtraPaths" is the content library required for smart prompts.
8. AndyPython plug-in
A smart reminder plug-in for Python. The keywords and functions to be prompted can be set in PackagesAndyPythonPythonCompletions. py.
9. AndyJS2 plug-in
A plug-in for Javsscript and jquery smart prompts.
10. jquery plugin
Jquery prompt library.
11. Ctags plug-in
This plug-in allows you to quickly locate the function definition.
12. To avoid gibberish when opening a file containing Chinese characters, you must first install the GBK Encoding Support plug-in and then install the ConvertToUTF8 plug-in.
If a friend finds it annoying to have a pop-up window when he does not register, here is a solution:
Open the sublime_text.exe file in the sublime text 2 installation directory with a hexadecimal Editor (I use UltraEdit here). Back up the file before that. If the file is not cracked, it can be restored and then located at the row 000CBB70, locate 8A C3, change it to B0 01, and save it,
Sublime Text 2 is only introduced so much for the moment. If you are interested in some plug-ins, you can find the relevant information on github. Let's try the convenience of sublime text2.