mac下的sublime Open in Browser不能识别中文名解决办法

问题原因:

在使用sublime的open in browser的时候遇到一个很dt的问题, 就是如果我要打开的html文件名是全英文的还好, 但如果文件名中有中文就凉凉, 会报下面的错

在这里插入图片描述

按照报的错以为是python版本有问题, 装了python3还是不行, 后来以下载的sublime有问题, 从新卸装整了好几遍还是有这个问题, 后来想到可能方向错了, 于是在网上找 Open in Browser不能识别中文名解决, 找到解决办法, 于由原答案比较乱, 自己总结下:

具体原因还是因为sublime不支持文件名中文情况下以浏览器的形式打开, (不排除另外, 另一个朋友的就可以打开, 这是主要是打不开的解决办法)


方法一: 将中文名的html文件,改成英文名的html文件来预览。(不推荐!)

方法二: sublime text, 安装插件SideBarEnhancements,使用插件的“open in browser”功能。(推荐!), 安装SideBarEnhancements也有两种办法, 这里我使用的是第二种

方法一, 使用Package Control 安装.(过程网上很多, 可以百度)

方法二, 使用git下载安装包: https://github.com/lyz8jj0/SideBarEnhancements.git

在这里插入图片描述
通过 Preferences --> Browse Packages… 打开Packages目录, 将git下来的SideBarEnhancements放入sublime的中Packages中, 然后配置快捷键:Preferences --> Package Settings --> Side Bar --> Key Bindings - User

 复制如下代码:

 mac如下
[
  // 习惯command+b默认Chrome
  { "keys": ["command+b"], "command": "side_bar_files_open_with",
    "args": {
      "paths": [],
      "application": "/Applications/Google Chrome.app",
      "extensions":".*"
    }
  },

  // Safari
  { "keys": ["command+2"], "command": "side_bar_files_open_with",
    "args": {
      "paths": [],
      "application": "/Applications/Safari.app",
      "extensions":".*"
    }
  },

  // Firefox
  { "keys": ["command+3"], "command": "side_bar_files_open_with",
    "args": {
      "paths": [],
      "application": "/Applications/Firefox.app",
      "extensions":".*"
    }
  }
]


Windows如下:

[
    { "keys": ["ctrl+shift+c"], "command": "copy_path" },
    //chrome
    { "keys": ["f1"], "command": "side_bar_files_open_with",
        "args": {
            "paths": [],
            "application": "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe",
            "extensions":".*" //匹配任何文件类型
        }
    },
    //firefox
    { "keys": ["f2"], "command": "side_bar_files_open_with",
        "args": {
            "paths": [],
            "application": "D:\Program Files\Mozilla Firefox\firefox.exe",
            "extensions":".*"
        }
     },
    //ie
    { "keys": ["f4"], "command": "side_bar_files_open_with",
        "args": {
            "paths": [],
            "application": "C:\Program Files\Internet Explorer\iexplore.exe",
            "extensions":".*"
        }
    },
    //safari
    { "keys": ["f5"], "command": "side_bar_files_open_with",
        "args": {
            "paths": [],
            "application": "D:\Program Files\Safari\safari.exe",
            "extensions":".*"
        }
    }
]

保存重启Sublime Text, 尝试通过快捷键启动, 成功

猜你喜欢

转载自blog.csdn.net/weixin_39973810/article/details/89107953