Change automatic qml reformatting column wrapping



  • In QtCreator it is possible to automatically format QML files using Tools > Qml/Js > Reformat file. The reformatting works well except that I would like to change the column value used to wrap code onto the next line from 80 to a higher value. Does anyone know how to do this?



  • I found a solution (sort of). Unfortunately the line length is hard coded in a file called qmljsreformatter.cpp which is built as a part of the qmljs.dll. So there are two ways you can change the line length that the QML / Javascript formatter uses:

    1. Get the Qt Creator source code and build a version yourself with the maxLineLength set to whatever you want.

    2. if you have Qt Creator 5.1 you could patch the qmljs.dll's bytes yourself using a hex editor to set the line length to a more sensible value of 125.
      @
      Replace 0x64 0x7e 0x17 0xff with 0x7d 0x7e 0x17 0xff
      Replace 0x10 0x83 0xe8 0x32 with 0x10 0x83 0xe8 0x4b
      Replace 0x50 0x7e 0x19 0x8b with 0x7d 0x7e 0x19 0x8b
      Replace 0x4d 0x89 0x44 0x24 with 0x7a 0x89 0x44 0x24
      @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.