If there exists a tool to automatically prettify my js code then I would much rather use that package.
I want to expand everything such that a statement like this:
var n=x+(y+(z/k))-123;
turns into:
var n = x + (y + (z / k)) - 123;
However, for the moment, I want to convert all my cramped =, ==, and ===, statements into padded versions of themselves.
I tried using something like :%s/[^ ]==[^ ]/ == /g but the problem with that is that it clips the preceeding and proceeding character.
In Vim, you could use something like:
Explanation:
s– substitute!– start pattern\s*– zero or more whitespace\(– start group[!<>=/*+-]\+– one or more of!<>=/*+-\)– end of group\s*zero or more whitespace!end of pattern, beginning of replacement<space>\1<space>– the matched group padded by space!– End of replacementg– globally on a lineBut if you want to prettify code and stick to a defined coding standard, you’re better off using a tool like Artistic Style.