LingYanSi / blog

博客
https://github.com/LingYanSi/blog/issues
9 stars 0 forks source link

vsc/vscode #69

Open LingYanSi opened 7 years ago

LingYanSi commented 7 years ago

vscode是微软基于chrome内核开发的代码编辑器,截止于2017年来看,是要比atom使用起来更加流畅

LingYanSi commented 7 years ago

plugins

LingYanSi commented 7 years ago

快捷键

working files切换

一个编辑区里,vsc是不缓存的,毕竟是js写的,相对较弱,这其实是vsc的一个优化 所以cmd + p 打开了文件之后,之前的文件就找不到了 实际上都存到working files里了,只要我们切换working files即可 mac下ctrl + -和shift+ctrl + -切换当前working files

LingYanSi commented 7 years ago
// 将设置放入此文件中以覆盖默认设置
{ 
    "files.exclude": {
        "**/.git": true,
        "**/.svn": true,
        "**/.hg": true,
        "**/CVS": true,
        "**/.DS_Store": true,
        "**/tmp": true,
        "**/node_modules": true,
        "**/bower_components": true,
        "**/dist": true,
        "**/static": true,
        "**/static1": true
    },
    "files.watcherExclude": {
        "**/.git/objects/**": true,
        "**/.git/subtree-cache/**": true,
        "**/node_modules/**": true,
        "**/tmp/**": true,
        "**/bower_components/**": true,
        "**/dist/**": true,
        "**/static": true,
        "**/static1": true
    },
    "search.exclude": {
        "**/node_modules": true,
        "**/bower_components": true,
        "**/static": true,
        "**/static1": true
    },
    "editor.fontSize": 14,
    "javascript.implicitProjectConfig.checkJs": true,
    "atomKeymap.promptV3Features": true,
    "editor.multiCursorModifier": "alt", // 多点修改,不然会覆盖cmd + click 跳转定义
    "editor.formatOnPaste": true,
    "workbench.colorTheme": "Atom One Dark",
    "editor.minimap.enabled": false,
    "workbench.iconTheme": "file-icons"
}
LingYanSi commented 7 years ago

jsconfig.json

对与前端框架这类相对单一、简单的项目我们并不需要jsconfig.json,vscode默认已经做的很好了 对于前后端混合的项目,就需要在client/server文件夹内各自建一个文件了

web前端项目

{
    "compilerOptions": {
        "target": "es6",
        "jsx": "react",
        "module": "commonjs",
        "baseUrl": "./src",
        "experimentalDecorators": true,
        "paths": {
          "wpt": ["main"]
        }
    },
    "include": [
        "src/**/*"
    ]
}

paths与webpack alias类似,其对应的路径以baseUrl为基准。上述配置,可提升文件跳转,代码提示。

node文件夹

{
    "compilerOptions": {
        "target": "ES6",
        "module": "commonjs",
        "baseUrl": "./"
    },
    "exclude": [
        "node_modules"
    ]
}

为了不写index也可以跳转module使用commonjs模式 当我们使用alias的时候,需要设置baseUrl,不然vscode不知道你的真实目的 exclude去除掉不需要解析的文件夹比如 node_modules/dist等