- ubuntu20.04安装vscode(注意:卸载时记得删除/home/lzy/.vscode/和/home/lzy/.config/Code才可以卸载干净!)
- 鼠标滑轮调整字体大小:再setting.json中加入
"editor.mouseWheelZoom": true,
- 解决vscode没有代码提示
- VSCode Cpptools 不提示类成员变量的一种解决方案
- vscode 秒出提示,增加速度效率
- 生成文件头部注释和函数注释的插件(函数头注释快捷键ctrl+alt+t,文件注释快捷键ctrl+alt+i)
-
ssh软件远程登录及免密登录(注意服务器(Linux端)authorized_keys(公钥内容)文件放在
\root\.ssh
下,那ssh登录账号为root,若放在\home\lzy\.ssh\
下账户为lzy) - ssh插件远程登录失败,Windows可以登录
- vscode如何自动生成函数注释
- vscode文件模板 (其中的$1、$2、$3…表示的意思是光标出现在哪里,你希望第一次光标出现在什么位置,就在那个写一个$1,以此类推。光标切换通过tab建)
- 完全卸载干净(包括插件和配置)
注意:若代码提示有问题或某种插件功能出问题,直接删除setting.json文件。若配置都没问题,但是远程服务器某些功能出问题,断开连接重启即可。
- windows在
C:\Users\lenovo\AppData\Roaming\Code\User\setting.json
- linux在
/home/lzy/.config/Code/Usr/settings.json
vscode配置(复制直接用)
以下为如下几个功能:
{
{
{
"editor.fontLigatures": false,
"editor.mouseWheelZoom": true,
"editor.suggest.snippetsPreventQuickSuggestions": false,
"editor.quickSuggestionsDelay": 0,
"editor.hover.delay": 0,
"tabnine.experimentalAutoImports": true,
"remote.SSH.path": "D:\\Git\\usr\\bin\\ssh.exe",
"remote.SSH.remotePlatform": {
"192.168.0.201": "linux",
"192.168.0.101": "linux",
"192.168.0.100": "linux"
},
//koroFileHeader插件配置
"fileheader.configObj": {
// 移动光标到`Description :`所在行
"moveCursor": true,
//新建文件自动添加头部注释
"createHeader": true,
//头部注释等宽设置为true开启
"wideSame": true,
//字段长度 默认为13
"wideNum": 13,
// 函数注释等宽设置 设为0 即为关闭
"functionWideNum": 13,
// 默认开启自动添加头部注释,当文件没有设置头部注释时保存会自动添加
"autoAdd": true,
// 默认开启
"autoAlready": true,
//createFileTime默认为此文件的创建时间,将该字段设为false即可更改为当前注释的插入时间。
"createFileTime": true,
// 默认格式 时间显示格式
"dateFormat": "YYYY-MM-DD HH:mm:ss",
// 禁止.json .md文件,自动添加头部注释
"prohibitAutoAdd": [
"json",
"md"
],
// \ 路径要转义 所以要写两遍
"filePathColon": "/",
// 头部注释前面插入内容
"beforeAnnotation": {
// py文件默认,可修改
"py": "# !usr/bin/env python\n# -*- coding:utf-8 -*-\n",
// 所有文件的头部注释都在前面增加一个换行(除了py)
"*": " "
},
// 尾部注释前面插入内容
"afterAnnotation": {
// 所有文件的头部注释都在最后一行增加一个换行
"*": " "
},
"language": {
// 一次匹配多种文件后缀文件 不用重复设置
"h/c/hpp/cpp": {
"head": "/*************************************************************************************",
"middle": " * @",
"end": " *************************************************************************************/"
},
"py": {
"head": "'''",
"middle": " ",
"end": "'''"
}
}
},
// 在光标处插入函数注释,默认配置:{'description':'','param':'','return':''}
"fileheader.cursorMode": {
"param": "",
"return": "",
"version": "1.0",
"name": "liuziyan",
"Date": "Do not edit"
},
// 头部注释,默认设置:{'Author':'your name','Date':'Do not edit','LastEditors':'your name','LastEditTime':'Do not edit','Description':'file content'}
"fileheader.customMade": {
"custom_string_obkoro1_copyright": "Copyright ${now_year} liuziyan, All Rights Reserved. ",
"Author": "liuziyan",
"version":"1.0",
"Date": "Do not edit", // 设置后默认设置文件生成时间
"Descripttion":"",
"Other":"无",
"Instructions":"",
"LastEditTime": "Do not edit", // 设置后,保存文件更改默认更新最后编辑时间
"FilePath": "Do not edit", // 设置后,默认生成文件相对于项目的路径
},
"files.associations": {
"*.c": "c"
},
"workbench.iconTheme": "vscode-icons",
"files.autoSave": "afterDelay",
"code-runner.defaultLanguage": "c",
"code-runner.executorMap": {
"python": "python",
"c": "cd $dir && gcc $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt"
},
/* 设置是否在每次运行前清除之前的输出(默认为 false)*/
"code-runner.clearPreviousOutput": true,
/* 设置是否在运行前保存所有文件(默认为false) */
"code-runner.saveAllFilesBeforeRun": false,
/* 设置是否在运行前保存当前文件(默认为false)*/
"code-runner.saveFileBeforeRun": false,
}
{
"editor.fontLigatures": false,
"editor.mouseWheelZoom": true,
"editor.suggest.snippetsPreventQuickSuggestions": false,
"editor.quickSuggestionsDelay": 0,
"editor.hover.delay": 0,
"remote.SSH.path": "D:\\Git\\usr\\bin\\ssh.exe",
"remote.SSH.remotePlatform": {
"192.168.0.201": "linux",
"192.168.0.101": "linux",
"192.168.0.100": "linux"
},
"files.associations": {
"*.c": "c"
},
"workbench.iconTheme": "vscode-icons",
"files.autoSave": "afterDelay",
//koroFileHeader插件配置
"fileheader.configObj": {
// 移动光标到`Description :`所在行
"moveCursor": true,
//新建文件自动添加头部注释
"createHeader": true,
//头部注释等宽设置为true开启
"wideSame": true,
//字段长度 默认为13
"wideNum": 13,
// 函数注释等宽设置 设为0 即为关闭
"functionWideNum": 13,
// 默认开启自动添加头部注释,当文件没有设置头部注释时保存会自动添加
"autoAdd": true,
// 默认开启
"autoAlready": true,
//createFileTime默认为此文件的创建时间,将该字段设为false即可更改为当前注释的插入时间。
"createFileTime": true,
// 默认格式 时间显示格式
"dateFormat": "YYYY-MM-DD HH:mm:ss",
// 禁止.json .md文件,自动添加头部注释
"prohibitAutoAdd": [
"json",
"md"
],
// \ 路径要转义 所以要写两遍
"filePathColon": "/",
// 头部注释前面插入内容
"beforeAnnotation": {
// py文件默认,可修改
"py": "# !usr/bin/env python\n# -*- coding:utf-8 -*-\n",
// 所有文件的头部注释都在前面增加一个换行(除了py)
"*": " "
},
// 尾部注释前面插入内容
"afterAnnotation": {
// 所有文件的头部注释都在最后一行增加一个换行
"*": " "
},
"language": {
// 一次匹配多种文件后缀文件 不用重复设置
"h/c/hpp/cpp": {
"head": "/*************************************************************************************",
"middle": " * @",
"end": " *************************************************************************************/"
},
"py": {
"head": "'''",
"middle": " ",
"end": "'''"
}
}
},
// 在光标处插入函数注释,默认配置:{'description':'','param':'','return':''}
"fileheader.cursorMode": {
"param": "",
"return": "",
"version": "1.0",
"name": "liuziyan",
"Date": "Do not edit"
},
// 头部注释,默认设置:{'Author':'your name','Date':'Do not edit','LastEditors':'your name','LastEditTime':'Do not edit','Description':'file content'}
"fileheader.customMade": {
"custom_string_obkoro1_copyright": "Copyright ${now_year} liuziyan, All Rights Reserved. ",
"Author": "liuziyan",
"version": "1.0",
"Date": "Do not edit", // 设置后默认设置文件生成时间
"Descripttion": "",
"Other": "无",
"Instructions": "",
"LastEditTime": "Do not edit", // 设置后,保存文件更改默认更新最后编辑时间
"FilePath": "Do not edit", // 设置后,默认生成文件相对于项目的路径
},
"tabnine.experimentalAutoImports": true,
"code-runner.runInTerminal": true,
"code-runner.defaultLanguage": "c",
"code-runner.executorMap": {
"python": "set PYTHONIOENCODING=utf8 && python $fullFileName",
"c": "chcp 65001 && clear && cd $dir && gcc *.c -o $fileNameWithoutExt.exe && $dir$fileNameWithoutExt.exe",
},
/* 设置是否在每次运行前清除之前的输出(默认为 false)*/
"code-runner.clearPreviousOutput": true,
/* 设置是否在运行前保存所有文件(默认为false) */
"code-runner.saveAllFilesBeforeRun": false,
/* 设置是否在运行前保存当前文件(默认为false)*/
"code-runner.saveFileBeforeRun": false,
"vsicons.dontShowNewVersionMessage": true,
"workbench.editor.enablePreview": false,
"remote.SSH.showLoginTerminal": true,
}
用户代码片段(系统编程)
// Place your snippets for c here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
// "Print to console": {
// "prefix": "log",
// "body": [
// "console.log('$1');",
// "$2"
// ],
// "description": "Log output to console"
// }
{
"kernelcode": {
"prefix": "kernelcode",
"body": [
"#include <linux/init.h>",
"#include <linux/kernel.h>",
"#include <linux/delay.h>",
"#include <linux/ide.h>",
"#include <linux/types.h>",
"#include <linux/module.h>",
"#include <linux/errno.h>\n",
"#ifdef _VSCODE",
" #define __init",
" #define __exit",
"#endif\n",
"static int __init x_init(void)",
"{",
" return 0;",
"}\n",
"static void __exit x_exit(void)",
"{\n",
"}\n",
"#ifndef _VSCODE",
" module_init(x_init);",
" module_exit(x_exit);\n",
" MODULE_AUTHOR(\"LiuZiyan.com\");",
" MODULE_LICENSE(\"GPL\");",
"#endif"
],
"description": "Log output to console"
}
}
内核代码模块
// Place your snippets for c here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
// "Print to console": {
// "prefix": "log",
// "body": [
// "console.log('$1');",
// "$2"
// ],
// "description": "Log output to console"
// }
{
"kernelcode": {
"prefix": "kernelcode",
"body": [
"#include <linux/init.h>",
"#include <linux/kernel.h>",
"#include <linux/delay.h>",
"#include <linux/ide.h>",
"#include <linux/types.h>",
"#include <linux/module.h>",
"#include <linux/errno.h>\n",
"#ifdef _VSCODE",
" #define __init",
" #define __exit",
"#endif\n",
"static int __init x_init(void)",
"{",
" return 0;",
"}\n",
"static void __exit x_exit(void)",
"{\n",
"}\n",
"#ifndef _VSCODE",
" module_init(x_init);",
" module_exit(x_exit);\n",
" MODULE_AUTHOR(\"LiuZiyan.com\");",
" MODULE_LICENSE(\"GPL\");",
"#endif"
],
"description": "Log output to console"
}
}