vscode 基本配置和使用 - jcuan - 博客园
    Monday, January 22, 2018
    12:58 PM
    vscode 基本配置和使用
    快捷键
    在terminal打开vccode code
    ctrl+p 查看搜索打开目录下的所有的文件
    ctrl+shift+p 或者 F1 打开控制台
    alt+shift+up/down 列选择
    alt+up/down 选中后使用快捷键,整块代码向上/下移动
    alt+click Multiple cursors多处编辑(注:ubuntu和本身快捷键冲突,按alt会弹出菜单,需要设置gsettings set org.gnome.desktop.wm.preferences mouse-button-modifier “”)
    ctrl+ 将一个文档分分为两个窗口,最多三个
    ctrl+tab 切换打开的tab栏,按tab选择
    ctrl+g 跳转到指定的行
    ctrl+shift+f 在打开的文件夹中寻找(可以选择文件搜索范围,支持正则表达式,反向引用:$1)
    ctrl+f 在当前文件查找
    ctrl+h在当前文件中
    shift+alt+鼠标 块选择
    ctrl+` 启动终端
    ctrl+/ 加/解注释
    folding折叠

    • Fold (Ctrl+Shift+[) 折叠所在的这个部分
    • Unfold (Ctrl+Shift+]) 取消所在部分的折叠

    Fold All (Ctrl+K Ctrl+0) 折叠当前编辑文件的所有可折叠部分

    • Unfold All (Ctrl+K Ctrl+J) 取消当当前文件所有折叠
    • Fold Level X (Ctrl+K Ctrl+2 for level 2) 折叠所有level x(还可以用 ctrl+3、ctrl+4等)的缩进去(除了当前编辑位置所在的)

    控制台Command Palette
    不一定要输入完整的命令,会有提示的

    • theme、setting、keybord(快捷键)、snip、fold
    • git(各种操作)

    比如:git checkout
    蓝色:改变的行,绿色:新的行,红色尖尖:被删除的行
    选项里:撤销上次提交、显示git信息
    使用和配置
    基本配置
    自动保存
    在用户配置文件中配置,可以通过控制台熟读setting快速打开
    files.autoSave: 可以有以下的值
    off - to disable auto save.
    afterDelay - to save files after a configured delay.
    onFocusChange - to save files when focus moves out of the editor of the dirty file.
    onWindowChange - to save files when the focus moves out of the VS Code window.
    files.autoSaveDelay: Configures the delay in milliseconds when files.autoSave is configured to afterDelay.
    代理
    详情见
    Note: VS Code supports http and https proxies, but not SOCKS proxies.
    tasks
    tasks就是一些预定义的任务,必须在文件夹下才可以运行(因为人家需要有配置文件嘛)
    定义自己的task
    控制台输入task,然后就知道怎么做了,后边选others(任意任务),有示例
    command and tasks[]
    同一命令,不同参数
    {
    “version”: “0.1.0”,
    “command”: “echo”,
    “isShellCommand”: true,
    “args”: [],
    “showOutput”: “always”,
    “echoCommand”: true,
    “suppressTaskName”: true,
    “tasks”: [
    {
    “taskName”: “hello”,
    “args”: [“Hello World”]
    },
    {
    “taskName”: “bye”,
    “args”: [“Good Bye”]
    }
    ]
    }
    running task commands through a shell command
    {
    “version”: “0.1.0”,
    “command”: “sh”,
    “args”: [“-c”],
    “isShellCommand”: true,
    “showOutput”: “always”,
    “suppressTaskName”: true,
    “tasks”: [
    {
    “taskName”: “make”,
    “args”: [“make”]
    },
    {
    “taskName”: “ls”,
    “args”: [“ls”]
    }
    ]
    }
    也许配置中会使用到的变量
    {file} 当前打开的文件
    {fileBasename} 当前打开文件的文件名
    {fileExtname} 当前打开文件的拓展名,如.json
    {env.Name} (e.g. ${env.PATH})
    Editor Groups分屏
    Ctrl+1 go to the leftmost editor group.
    Ctrl+2 go to the center editor group.
    Ctrl+3 go to the rightmost editor group.
    Ctrl+W close the active editor.
    snippets设置和使用代码块
    “For Loop”: {
    “prefix”: “for”,
    “body”: [
    “for (var ${index} = 0; ${index} < ${array}.length; ${index}++) {“,
    “\tvar ${element} = {index}];”,
    “\t$0”,
    “}”
    ],
    “description”: “For Loop”
    },

    • For Loop 代码块的名字
    • prefix 定义触发的关键词
    • body 内容
    • description 输入关键词出发snippets的提示信息

    可选的变量:

    • $1, $2 tab 停止的地方
    • ${id} 定义变量(填空的地方),如 ${lable}是变量

    相同id的文件会被绑定到一起同时编辑

    如果你的代码含有
    { or}, 需要转义,如{ and \}
    配置内部使用的terminal
    参见cmder基本配置和使用
    插件推荐

    • amVim

    可以像使用wim那样使用VSC

    • vscode-icons

    简直棒,可以在文件前显示语言logo之类的图标

    • vscode-fileheader

    在文件前边添加注释
    特定语言
    html
    开头输入!然后按tab,整个html框架补全
    输入标签名称然后tab,补全标签
    php

    • php Debug棒的不行

    需要在setting.json里设置”php.validate.executablePath”: “/usr/bin/php”

    • php IntelliSense Crane 补全超级牛
    • PHP IntelliSense 另一个,能搜索函数、格式化代码
    • 好像要一个可以自动生成标准doc注释的插件,不过暂时没找到

    C

    • C/C++ 微软出的

    note:觉得这些拓展的功能还是太弱了,居然上边定义的变量都没有提示。kdevelop还不错,界面也挺棒的,强烈推荐。
    debug需要使用make、gdb 。右击断点可以设置条件断点,监控栏可以监控一些表达式。
    配置示例:
    lanuch.json需要增加或者修改的,都有提示
    “program”: “{workspaceRoot}”],
    “pattern”: {
    “regexp”: “^(.):(\d+):(\d+):\s+(warning|error):\s+(.)$”,
    “file”: 1,
    “line”: 2,
    “column”: 3,
    “severity”: 4,
    “message”: 5
    }
    }
    }
    ]
    }
    markdown

    • markdown theme kit
    • 好看的css找了一下午,好多挺好看css的和主题不搭

    有好看的可不可以分享一下~~
    python
    拓展推荐:python 就是搜python排名最高那个,安装之后右击查看强大功能
    调试配置(只截取修改部分):
    在用户配置(可通过console控制台里输setting打开)里面将python改为运行python命令的地址,如果在终端中可以直接运行python命令,只输入python也可以
    下边python文件中的pythonpath也是指的python命令地址
    “configurations”:
    {
    “name”: “Python”,
    “type”: “python”,
    “request”: “launch”,
    “stopOnEntry”: true,
    “pythonPath”: “{file}”,
    “debugOptions”: [
    “WaitOnAbnormalExit”,
    “WaitOnNormalExit”,
    “RedirectOutput”
    ]
    },
    {
    “name”: “Flask”,
    “type”: “python”,
    “request”: “launch”,
    “stopOnEntry”: false,
    “pythonPath”: “${config.python.pythonPath}”, //如果需要用venv里面的python,需要把这个改成python命令位置,类似这样的/home/jcuan/code/python/project/venv/bin/python
    “program”: “/home/jcuan/code/python/project/venv/bin/flask”, //flask命令地址,flask0.11之后可以通过flask run的方式来运行python,不过需要一些配置,比如FLASK_APP环境变量的设置,可以通过运行 flask —help 和flask run —help来查看帮助
    “env”: {
    “FLASK_APP”: “${workspaceRoot}/app/init.py” //设置必要环境变量,这个文件就是你项目开始的那个文件
    },
    “args”: [ //运行flask命令的参数
    “run”,
    “—no-debugger”,
    “—no-reload”
    ],
    “debugOptions”: [
    “WaitOnAbnormalExit”,
    “WaitOnNormalExit”,
    “RedirectOutput”
    ]
    }
    我的init.py大概像这样的,
    from flask import Flask
    app = Flask(name, static_folder=’statics’, static_url_path=’/static’)
    app.config.from_pyfile(‘config.py’)
    import hello
    分类:

    好文要顶 关注我 收藏该文
    [vscode 基本配置和使用 - jcuan - 博客园 - 图1
    计算机生成了可选文字:
    计算机生成了可选文字:
    jcuan 关注 - 0 粉丝 - 2
    +加关注
    1
    0
    « 上一篇:mongodb重命名集合、数据库 » 下一篇:phpDocumentor生成文档
    posted @ 2016-09-28 21:52 jcuan 阅读(33366) 评论(1) 编辑 收藏
    已使用 Microsoft OneNote 2016 创建。