vscode格式化proto文件 |
您所在的位置:网站首页 › Mac文件格式化 › vscode格式化proto文件 |
目录
安装vscode-proto3插件安装clang-format 可执行程序格式化代码另一种格式化方式
安装vscode-proto3插件
在应用商店中安装vscode-proto3插件 执行命令查看是否安装成功clang-format -help OVERVIEW: A tool to format C/C++/Java/JavaScript/Objective-C/Protobuf/C# code. If no arguments are specified, it formats the code from standard input and writes the result to the standard output. If s are given, it reformats the files. If -i is specified together with s, the files are edited in-place. Otherwise, the result is written to the standard output. USAGE: clang-format [options] [ ...] OPTIONS: 格式化代码此时在proto文件上按 ctrl+shift+i (linux下) 尝试格式化代码,为了方便可以在 setting.json中配置"editor.formatOnSave": true, 保存时自动格式化代码 另一种格式化方式以上格式化程序使用的是proto3的方式进行的格式化,也可以尝试使用clang-format的方式。 在应用商店安装 Clang-Format 插件,
clang-format可以使用自定义的配置文件来格式化代码: 在项目的根目录下(或者项目的任意上级目录下)新建一个.clang-format或_clang-format文件 配置内容可以参考官网:https://clang.llvm.org/docs/ClangFormatStyleOptions.html 除此之外无需其它配置,格式化代码即会根据该clang-format文件内容来格式化代码。 .clang-format文件示例: Language: Proto # # 每行字符的限制,0表示没有限制 ColumnLimit: 1000 # 对齐连续的尾随的注释 AlignTrailingComments: true # 在一个注释中引入换行的penalty PenaltyBreakComment: 1000 # 允许重新排版注释 ReflowComments: true |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |