@echo off&setlocal enabledelayedexpansion
set StrPath="D:\Program Files (x86)\Sublime Text 3 中文优化版\Data\Packages\User"
::此行命令读取脚本中包含“::Str_JAVA-run.sublime-build::”字样的行号,然后把该行后面的内容写入指定文件中
for /f "tokens=1 delims=:" %%a in ('findstr /n "^::Str_JAVA-run.sublime-build::$" "%~0"') do more +%%a "%~0">JAVA-run.sublime-build
pause
exit
::此内容必须写在脚本最末。
::Str_JAVA-run.sublime-build::
{
"cmd": ["javac","-encoding","UTF-8","-d",".","$file"],
"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
"selector": "source.java",
"encoding":"GBK",
//执行完上面的命令就结束
// 下面的命令需要按Ctrl+Shift+b来运行
"variants":
[
{
"name": "Run",
"shell": true,
"cmd" : ["start","cmd","/c", "java ${file_base_name} &echo. & pause"],
// /c是执行完命令后关闭cmd窗口,
// /k是执行完命令后不关闭cmd窗口。
// echo. 相当于输入一个回车
// pause命令使cmd窗口按任意键后才关闭
"working_dir": "${file_path}",
"encoding":"GBK"
}
]
}