NppExec (コマンドの実行)

NppExecは、Notepad++上でコマンドを実行するためのプラグインです。

プラグインのインストール

Notepad++のANSI版には最初からこのプラグインが同梱されていますが、Unicode版は別途ダウンロードする必要があります。

Notepad++ Plugins - Browse /NppExec at SourceForge.net

コマンド一覧

コマンド 説明
cls clear Console screen
cd shows current path
cd <path> changes current directory (absolute or relative)
cd <drive:\path> changes current drive and directory
dir lists subdirs and files
dir <mask> lists subdirs and files matched the mask
dir <path\mask> lists subdirs and files matched the mask
echo <text> prints a text in the Console
set shows all user's variables
set <var> shows the value of user's variable <var>
set <var> = <value> sets the value of user's variable <var>
set <var> ~ <math expression> calculates the math expression
unset <var> removes user's variable <var>
env_set <var> shows the value of environment variable <var>
env_set <var> = <value> sets the value of environment variable <var>
env_unset <var> removes/restores the environment variable <var>
inputbox "message" shows InputBox, sets $(INPUT)
inputbox "message" : initial_value InputBox, sets $(INPUT)
con_loadfrom <file> loads a file's content to the Console
con_load <file> see "con_loadfrom"
con_saveto <file> saves the Console's content to a file
con_save see "con_saveto"
sel_loadfrom <file> replace current selection with a file's content
sel_load <file> see "sel_loadfrom"
sel_saveto <file> save the selected text to a file
sel_saveto <file> : <encoding> save the selected text to a file
sel_save <file> : <encoding> see "sel_saveto"
sel_settext <text> replace current selection with the text specified
sel_settext+ <text> replace current selection with the text specified
npp_exec <script> execute commands from specified script
npp_exec <file>※1 execute commands from specified file
npp_close close current file in Notepad++
npp_close <file>※1 close specified file opened in Notepad++
npp_console <on/off/keep> show/hide the Console window
npp_console <1/0/?> show/hide the Console window
npp_open <file> open a file in Notepad++
npp_open <mask> open files matched the mask
npp_open <path\mask> open files matched the mask
npp_run <command> run external process/command
npp_save save current file in Notepad++
npp_save <file>※1 save a file in Notepad++ (if it's opened)
npp_saveall save all modified files
npp_switch <file>※1 switch to specified opened file
npp_sendmsg <msg> send a message (msg) to Notepad++
npp_sendmsg <msg> <wparam> message with parameter (wparam)
npp_sendmsg <msg> <wparam> <lparam> msg to Notepad++
sci_sendmsg <msg> send a message (msg) to current Scintilla
sci_sendmsg <msg> <wparam> message with parameter (wparam)
sci_sendmsg <msg> <wparam> <lparam> msg to Scintilla
npe_cmdalias show all command aliases
npe_cmdalias <alias> shows the value of command alias
npe_cmdalias <alias> = removes the command alias
npe_cmdalias <alias> = <command> sets the command alias
npe_console <options> set/modify Console options/mode
npe_debuglog <on/off> enable/disable Debug Log
※1 これらのコマンドでは、ファイルのパスの指定が無視されます。

コマンドの一覧は、/plugins/doc/NppExec/NppExec.txtにあります。

コンソールでのみ使用できるコマンド

コマンド 説明
help show available commands
ver show plugin's version
CTRL+C terminate current child process
CTRL+BREAK terminate current child process

環境変数

環境変数の一覧は、/plugins/doc/NppExec/NppExec.txtにあります。

Notepad++ 環境変数

変数 説明
$(FULL_CURRENT_PATH) E:/my Web/main/welcome.html
$(CURRENT_DIRECTORY) E:/my Web/main
$(FILE_NAME) welcome.html
$(NAME_PART) welcome
$(EXT_PART) .html
$(NPP_DIRECTORY) the full path of notepad++'s directory
$(CURRENT_WORD) word(s) you selected in Notepad++
$(CURRENT_LINE) current line number
$(CURRENT_COLUMN) current column number

追加の環境変数

変数 説明
$(#0) C:/Program Files/Notepad++/notepad++.exe
$(#N), N=1,2,3... full path of the Nth opened document
$(LEFT_VIEW_FILE) current file path-name in primary (left) view
$(RIGHT_VIEW_FILE) current file path-name in second (right) view
$(PLUGINS_CONFIG_DIR) full path of the plugins configuration directory
$(CWD) current working directory of NppExec (use "cd" to change it)
$(ARGC) number of arguments passed to the NPP_EXEC command
$(ARGV) all arguments passed to the NPP_EXEC command after the script name
$(ARGV[0]) script name - first parameter of the NPP_EXEC command
$(ARGV[N]) Nth argument (N=1,2,3...)
$(RARGV) all arguments in reverse order (except the script name)
$(RARGV[N]) Nth argument in reverse order (N=1,2,3...)
$(INPUT) this value is set by the 'inputbox' command
$(INPUT[N]) Nth field of the $(INPUT) value (N=1,2,3...)
$(OUTPUT) this value can be set by the child process, see npe_console v+
$(OUTPUT1) first line in $(OUTPUT)
$(OUTPUTL) last line in $(OUTPUT)
$(MSG_RESULT) result of 'npp_sendmsg' or 'sci_sendmsg'
$(MSG_WPARAM) wParam (output) of 'npp_sendmsg' or 'sci_sendmsg'
$(MSG_LPARAM) lParam (output) of 'npp_sendmsg' or 'sci_sendmsg'
$(SYS.<var>) system's environment variable, e.g. $(SYS.PATH)

コマンドの保存

コマンドの実行画面にある[Save]ボタンをクリックすることで、入力したコマンドを保存できます。保存したコマンドは、実行画面の左下にあるメニューから簡単に呼び出せます。

オプション設定

メニューの【プラグイン → NppExec → Advanced Options】から設定できます。

ここでの設定は、/plugins/Config/NppExec.iniに保存されます。