改变packages安装路径
默认情况下,sublime的安装包在C:\Users\user_name\AppData\Roaming\Sublime Text 3目录下,要改变的话只需要在sublime的安装目录下新建一个Data文件夹,重启sublime,之后安装的包都放在Data下了。
这是重启后Data文件下下的内容:

安装sublimerepl
利用install package安装即可,以下用Python的使用做说明。在Data\Packages\SublimeREPL\config\Python里,有个Default.sublime-commands文件,内容如下:
[
{
"caption": "SublimeREPL: Python",
"command": "run_existing_window_command", "args":
{
"id": "repl_python",
"file": "config/Python/Main.sublime-menu"
}
},
{
"caption": "SublimeREPL: Python - PDB current file",
"command": "run_existing_window_command", "args":
{
"id": "repl_python_pdb",
"file": "config/Python/Main.sublime-menu"
}
},
{
"caption": "SublimeREPL: Python - RUN current file",
"command": "run_existing_window_command", "args":
{
"id": "repl_python_run",
"file": "config/Python/Main.sublime-menu"
}
},
{
"command": "python_virtualenv_repl",
"caption": "SublimeREPL: Python - virtualenv"
},
{
"caption": "SublimeREPL: Python - IPython",
"command": "run_existing_window_command", "args":
{
"id": "repl_python_ipython",
"file": "config/Python/Main.sublime-menu"
}
}
]
可以看到有运行Python、运行当前文件、调试当前文件等命令。
可以在sublime主界面依次点击Tools->SublimeREPL->python-,再点击相应的命令运行。
这样子有点麻烦,可以自行设置快捷键。在主界面点击Preferences->Key Binding设置,弹出的界面的左边是系统默认的快捷键,右边可以添加自定义的快捷键,初始为空。在右边放入如下内容:
[
{
"keys": ["ctrl+f12"],
"caption": "SublimeREPL: Python",
"command": "run_existing_window_command", "args":
{
"id": "repl_python",
"file": "config/Python/Main.sublime-menu"
}
},
{
"keys": ["ctrl+f5"],
"caption": "SublimeREPL: Python - PDB current file",
"command": "run_existing_window_command", "args":
{
"id": "repl_python_pdb",
"file": "config/Python/Main.sublime-menu"
}
},
{
"keys": ["f5"],
"caption": "SublimeREPL: Python - RUN current file",
"command": "run_existing_window_command", "args":
{
"id": "repl_python_run",
"file": "config/Python/Main.sublime-menu"
}
},
{
"command": "python_virtualenv_repl",
"caption": "SublimeREPL: Python - virtualenv"
},
{
"caption": "SublimeREPL: Python - IPython",
"command": "run_existing_window_command", "args":
{
"id": "repl_python_ipython",
"file": "config/Python/Main.sublime-menu"
}
}
]
可以看到我加了三个快捷键。之后按f5就可以运行当前文件;按ctrl+f5就可以调试当前文件;按ctrl+f12就可以运行python。当然,快捷键可以是随意的,只要不和已有的冲突就好了。
注意:需要提前安装好python,并设置相应的环境变量。
运行node
首先,点击Tools->Build System,查看是否有node的选项,没有的话点击New Build System,在弹出的界面中输入如下代码:
{
"cmd": ["node", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"working_dir": "${project_path:${folder}}",
"selector": "source.js",
"shell": true,
"encoding": "utf-8",
"windows": {
"cmd": ["node", "$file"]
}
}
保存为nodejs.sublime-build就好了。对于js文件,按下ctrl+b就可以运行了(sublime会根据后缀名自动识别当前的文件为js文件,并调用node来运行,而不是python)。
1.注意:需提前安装node,且设置环境变量。
2.注意:以上适用于64位的windows,对于32位的,有网友说:如果系统不是64位的话,上述代码中的cmd改成
"cmd": ["taskkill /f /im node.exe >nul 2>nul & node", "$file"],
wq,sbldancdztmbhp,wsl.
我去,sublime的anaconda真他妈不好配,我输了。
自定义Sublime Text的包安装位置与运行Node.js
本文介绍了如何更改Sublime Text的包安装路径到Data文件夹下,并详细讲解了安装与使用SublimeREPL运行Python,包括设置快捷键的方法。同时,文章还指导了如何配置Sublime Text以运行Node.js,包括创建新的构建系统并设置环境变量的要求。
1万+

被折叠的 条评论
为什么被折叠?



