Hacker News new | past | comments | ask | show | jobs | submit login

I can't speak to emacs, but vim has no problems with a program like this operating on the BufWritePre event. I use whitespace trimming and js-beautify that way already. This may or may not do a better job than js-beautify for it. I have it set as the equalprg so that vim will use beautify to format code on = when a visual selection is made.

From my vimrc:

> au FileType javascript setlocal equalprg=/usr/local/share/npm/bin/js-beautify\ -f\ -\ -q\ -t\ -j\ -w\ 140\ --good-stuff\ -b\ \"end-expand\"

edit: The same event (BufWritePre) is what I've got set for go fmt too. That IS a plugin, but it makes no significant difference as compared to js-beautify.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: