使用Notepad++開發python配置筆記


這是我在python學習過程中,收集整理的一些notepadd++環境配置方法。

1、配置制表符

Notepad++ ->"設置"菜單->"首選項"按鈕->制表符設置->python->取消默認,勾選轉換為空格。

2、配置調試工具

1. Notepad++ ->"運行"菜單->"運行"按鈕

2. 在彈出的窗口內輸入以下命令:

cmd /k cd /d "$(CURRENT_DIRECTORY)" & python "$(FILE_NAME)" & ECHO. & PAUSE & EXIT

然后點擊“保存”,隨意取一個名字,比如“RunPython”,為方便,配置一下快捷鍵(比如 Ctrl + F5),點OK即可。之后運行Python文件只要按配置的快捷鍵或者在運行菜單上點“RunPython”即可。

注意不要跟已有的快捷鍵沖突。查看已有的快捷鍵,可以點擊"運行"菜單->"管理快捷鍵"按鈕 查看

3. 命令解釋

cmd /k cd /d "$(CURRENT_DIRECTORY)" & python "$(FILE_NAME)" & ECHO. & PAUSE & EXIT

cmd /k python: 表示打開Cmd窗口,運行/k后邊的命令,並且執行完畢后保留窗口。此處即python(因為在環境變量里已經添加了Python目錄,所以這里不用指定Python程序的目錄,就可直接找到)

cmd /d:跳轉到后面指定的目錄,即$(CURRENT_DIRECTORY),意思是先cd到文件目錄,再用python命令運行程序。

$(CURRENT_DIRECTORY):Notepad++的宏定義,表示當前文件所在目錄。

$(FILE_NAME) :Notepad++的宏定義,表示當前文件名。

&:用來連接多條命令

ECHO.:目的是為了換行,重點是echo后面的"." ,可以去掉點試試會發生什么?

PAUSE: 表示運行結束后暫停(cmd中顯示“請按任意鍵繼續. . .”),等待一個按鍵繼續

EXIT: 表示“按任意鍵繼續. . .”后,關閉命令行窗口。

4.notepad++宏定義:

FULL_CURRENT_PATH
  the fully qualified path to the current document.
CURRENT_DIRECTORY
  The directory the current document resides in.
FILE_NAME
  The filename of the document, without the directory.
NAME_PART
  The filename without the extension.
EXT_PART
  The extension of the current document.
NPP_DIRECTORY
  The directory that contains the notepad++.exe executable that is currently running.
CURRENT_WORD
  The currently selected text in the document.
CURRENT_LINE
  The current line number that is selected in the document (0 based index, the first line is 0).
CURRENT_COLUMN
  The current column the cursor resides in (0 based index, the first position on the line is 0).

以上內容是我參考別人文章修改后的,解決了原文最后一個問題(cmd 后面加/d)

推薦再看看原文: http://www.cnblogs.com/zhcncn/p/3969419.html

3、自動換行插件

Python Indent 在線安裝即可。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM