Based on vim-shfmt
The Vim qmlfmt plugin runs qmlfmt to auto format the current buffer
You just need the qmlfmt
command
Obtain a copy of this plugin and place qmlfmt.vim
in your Vim plugin directory or be sensible and use something like Plug:
Plug 'a-dekker/vim-qmlfmt', { 'for': 'qml' }
or via vundle:
" qml formatter
Plugin 'a-dekker/vim-qmlfmt'
You can use the :Qmlfmt
command to run qmlfmt and automatically format the current buffer
You can also use the :Qmlfmt
command together with options. For example,
:Qmlfmt -t 4
:Qmlfmt -i 2
qmlfmt uses 4 spaces by default for auto formatting, so if you prefer to use 2 spaces, you can set the following in your .vimrc
file:
let g:qmlfmt_extra_args = '-i 2'
If you would like to auto format shell scripts on save, you can add the following to your vim config:
let g:qmlfmt_fmt_on_save = 1
The Vim qmlfmt plugin is open-sourced software licensed under the MIT license.