在使用vscode编辑md文件时,如果要用Typora经常需要右键在文件资源管理器打开,然后才能用Typora编辑,非常不方便,因此本文尝试了几个vscode插件。以下为使用总结:

1. Open in External App

使用Open in External App插件,该插件可以设定指定文件类型的打开方式,例如md,pdf,html等等:

在vscode的settings.json文件中加入以下配置即可:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
{
"openInExternalApp.openMapper": [
{
// represent file extension name
"extensionName": "md",
// the external applications to open the file which extension name is html
"apps": [
// openCommand can be shell command or the complete executable application path
// title will be shown in the drop list if there are several apps
{
"title": "Typora",
"isElectronApp": true,
},
]
},
]
}

评价是不太好用,经常没有反应,后来查看官方文档,发现原因:

该插件打开md文档时使用了第二种api,此方式无法打开路径存在非ascii字符的文件。因此起名时需要多加注意(不能有中文~~~)

2. Open in Typora

该插件则是专门面向Typora打开md文件的

首先需要将Typora安装路径添加到环境变量,然后在settings.json文件中添加以下内容:

1
2
3
4
5
6
7
8
9
10
11
12
"ego.power-tools.user": {
"buttons": [ {
"text": "Typora",
"tooltip": "使用Typora打开",
"action": {
"type": "command",
"command": "typora.open"
},
"onEditorCreated": "if ($vs.window.activeTextEditor.document.languageId === 'markdown') { $v['button'].enable(); $v['button'].color = ''; } else { $v['button'].disable(); $v['button'].color = 'grey';}",
"onEditorChanged": "if ($vs.window.activeTextEditor.document.languageId === 'markdown') { $v['button'].enable(); $v['button'].color = ''; } else { $v['button'].disable(); $v['button'].color = 'grey';}"
}]
}

结果报错,醉了~~~:

可能是太久没有更新导致出现的bug。