【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
相关推荐
内存不泄露3 小时前
性价比极高的中转平台
编辑器
嵌入式小站5 小时前
STM32 可移植教程 02:按键状态机,消抖、长按、释放一行也不用多写(实战篇)
chrome·vscode·stm32·单片机·嵌入式硬件
郝学胜_神的一滴6 小时前
Qt 高级开发 031:QListWidget图标布局实战
c++·qt
游戏开发爱好者87 小时前
iPhone真机调试有哪些方法?一次定位推送权限问题时整理出来的几种方案
ide·vscode·ios·objective-c·个人开发·swift·敏捷流程
Vertira7 小时前
如何对QT开发的软件进行打包[已解决]
开发语言·qt
大智兄8 小时前
128.配置qt(交叉)编译的路径---解决无法编译的问题
qt
youcans_8 小时前
从零搭建 STM32 VSCode 开发环境
vscode·stm32·单片机·嵌入式硬件
qinwsq10 小时前
keil编译第一个工程
编辑器
VidDown11 小时前
VidDown 工具站:视频分辨率技术
javascript·网络·编辑器·音视频·视频编解码·视频
黑科技研究僧13 小时前
蘑兔AI的12轨分轨功能:编曲师深度测评
人工智能·经验分享·vscode·学习·新媒体运营·音视频