edited tags
Martin Tournoij
  • 53.6k
  • 22
  • 170
  • 251
Source Link

Is there a simple way to require clean syntax before saving?

I currently use Ricardo Signes's plugin to allow me to use a single command to both check my Perl syntax and save my code only if it is syntactically correct. However, isn't there a simpler way to do this without a plugin and/or a lot of code?

I can save and then check the syntax for already saved files:

:w %<bar>! perl -c %

But that saves it no matter if the syntax is correct or not.

I read somewhere that this was supposed to be easy. Now, I've been Googling for it, but haven't been able to find it.