Their is a vim script called foldcol.vim but I can't say more.
Personnaly I will do :
"put every calculs on one line :%s/(/\r(\r/g :%s/)/\r)\r/g "delete all empty lines :g/^$/d "set fold as () to collapse them with "za" :set foldmethod=marker foldmarker=(,) "indent all text: gg=G
It should look like :
Result: ( ( 6*( k2+k3 ) ) *A123*k2*k3*( A12*A13*k2^2-2*A12*A13*k2*k3+A12*A13*k3^2-A123*k2^2 ) *( . . .
After working on it, remove indent : go to first line and then press :
gg<G............ "need to press dot to repeat 500gJ "to put all on one line