Posted on 18:40:00 by Xiaoyue and filed underNotepad ++,Python
Notepad ++Is an open-source text editor with powerful functions and ease of use. Edit and debugPythonThe editor used by the program or different ide people have different opinions. Without considering the use of debugging tools, VIM or Emacs users can naturally ignore other editors, but in windowsNotepad ++The editor is also a good choice.
I downloaded it on portableapps.com.Notepad ++Portable, which saves the required configuration files separately when you close the program, saving the trouble of reconfiguration on each machine.
Tab length and space conversion
BecausePythonStrict requirements on indentation. We set the tab to 4 spaces and modify it in Settings> preferences> Edit> tab settings.
Syntax highlighting
If the extension is set correctly,Notepad ++The system automatically recognizes the language and highlights the syntax. If you are not satisfied with the highlighted color or font, you can modify it in "Settings> language format settings.
Automatic completion
Notepad ++You can also set the Automatic completion and input prompt function in "Settings> preferences> Backup and Automatic completion.PythonThe files required for Automatic completion are included during installation and stored in "your_npp_dir/plugins/APIs" (see the official FAQ: auto-completion ). The default shortcut is Ctrl + space and CTRL + enter, which may conflict with the shortcut key of the input method,Notepad ++Can be customized.
Run the program
Click "Run-> Run" (F5 is the default shortcut) and enter:
CMD/k c:/python30/Python. EXE "$ (full_current_path)" & pause & Exit
Select "save" to set a shortcut key and name for this command, such as "run ".Python". You can directly press the custom shortcut key to run later. Note: If you want to modify this shortcut key, you can modify it in "Settings> Management shortcut key> run commands. There are several notes:
- To modify this command, you can only modify the shortcuts. xml file, which is saved inNotepad ++In the configuration fileNotepad ++May also be in the application data under Documents and Settings.
- $ (Full_current_path) indicates the complete path of the current file. This isNotepad ++For more macro definitions, see the official FAQ: Run external tools. Note:UseEnclose the quotation marks to prevent spaces in the middle of the path.
- Direct executionPythonThe. exe window will be closed automatically after running, so you needUseCmd. (InPython2.5 seems to be different, but 3.0 needs to be set like this .)
- CMD/K means to execute the following command and keep the window after execution. & Connects multiple commands. Pause indicates that the task is paused after the operation is completed, waiting for any button. Exit indicates closing the command line window. If CMD/C is used, exit can be saved.
More plug-ins
BecauseNotepad ++Supports extension of plug-ins, so you can use many useful plug-ins (the download page contains a list of plug-ins ). For example, there is a plug-in: nppexec, you canNotepad ++To make it easier to run commands and scripts. You can use this plug-in to setPython.
However, a problem with this plug-in is that the output result is returned only after the program runs successfully, so that you cannot observe the program running in real time. I wonder if there is any good solution?
2009-03-14up:
You can refresh the stdout buffer to solve the problem of untimely output.