I'm not Vim noob, but I'm not a professional either. If I have a segment, in this case javascript, such code
function foo(a,b,c,d) { if (one||two) { if (rhyme||reason) { return true; } return false; } }
and I will format it ( gg=G ), I get the following code:
function foo(a,b,c,d) { if (one||two) { if (rhyme||reason) { return true; } return false; } }
It is more aesthetically pleasing. However, if instead I wanted lower (or if I wanted to convert the above result into the following result):
function foo( a, b, c, d ) { if ( one || two ) { if ( rhyme || reason ) { return true; } return false; } }
Is there a way to instruct Vim how to parse the code? I can use a hack with regular expressions to search for brackets and spaces, but it falls apart if we consider all the operators ( !,%,*,-,+,=,/ )
source share