【QML】vscode安装QML格式化插件方法

1. 安装插件

拓展 => 搜索qml => 找到QML Format =>点击安装

2. 配置

  • 打开settings.json文件
    • ctl + shift + p,然后搜索settings
  • 修改settings.js内容
c 复制代码
{
    ...
    //添加以下内容

    // 根据自己电脑安装路径来填写qmlformat.exe的路径,注意转义符"\" => "\\"
    "qmlFormat.command": "D:\\Soft\\Qt6\\5.15.2\\mingw81_64\\bin\\qmlformat.exe",

    // 命令选项,这里官方写的是--normal,但是报错,改成-n就好了
    // qmlFormat的命令选项见附录
    "qmlFormat.extraArguments": ["-n"]
}

3. 使用

  • 鼠标右键选择格式化文档
  • 快捷键 shift + alt + F

附录

  • qmlFormat.exe 命令选项
c 复制代码
./qmlformat -h                                       
Usage: ./qmlformat [options] filenames
Formats QML files according to the QML Coding Conventions.

Options:
  -h, --help                  Displays help on commandline options.
  --help-all                  Displays help including Qt specific options.
  -v, --version               Displays version information.
  -V, --verbose               Verbose mode. Outputs more detailed information.
  -i, --inplace               Edit file in-place instead of outputting to
                              stdout.
  -f, --force                 Continue even if an error has occurred.
  -t, --tabs                  Use tabs instead of spaces.
  -w, --indent-width <width>  How many spaces are used when indenting.
  -n, --normalize             Reorders the attributes of the objects according
                              to the QML Coding Guidelines.
  -F, --files <file>          Format all files listed in file, in-place
  -l, --newline <newline>     Override the new line format to use (native macos
                              unix windows).

Arguments:
  filenames                   files to be processed by qmlformat
相关推荐
haiyu柠檬15 分钟前
IDEA和VSCode中好用的插件推荐
java·vscode·intellij-idea
aluluka18 分钟前
Emacs 折腾日记(三十四)—— org todo
编辑器·emacs
hqwest22 分钟前
码上通QT实战11--监控页面03-绘制湿度盘和亮度盘
开发语言·qt·绘图·自定义组件·部件·qpainter·温度盘
起个名字费劲死了27 分钟前
QT + Socket 客户端/服务端 公网通讯
服务器·c++·qt·socket
wzfj123452 小时前
vscode 安装 Serial Monitor 扩展
vscode·serial
qq_377572774 小时前
vscode markdown enter键不能添加多个空白行
ide·vscode
羊小猪~~5 小时前
【QT】-- QT基础类
开发语言·c++·后端·stm32·单片机·qt
secondyoung5 小时前
Git使用:rebase用法
c语言·经验分享·git·vscode
TDengine (老段)6 小时前
Node.js 语言连接器进阶指南
大数据·物联网·node.js·编辑器·vim·时序数据库·tdengine
起个名字费劲死了6 小时前
QT 学习:协同开发的程序如何汇总到主程序
qt