I found a useful line for my .vimrc file from here that makes any file beginning with #! on line 1 executable when I save it. Here's the line:au BufWritePost * if getline(1) =~ ^#! | silent !chmod +x <afile> | endifThis works great, as long as I don't have any syntax errors. But if I try to save a file with any syntax errors, if it has a shebang line on line 1 then vim gets glitchy when I save. This behavior completely goes away when I comment out this line. I don't understand the inner workings of vim well enough to diagnose this. Why does it cause glitches? Is there any way to make this more foolproof, or should I ditch this line altogether?EDIT:To be more specific, the issues only occur when I use :w and continue editing, not when I use :wq or :x. And it appears that the line or two of error messages that appears at the bottom of the screen shifts the screen up a line or two when they pop up.EDIT 2:I also just tried this other solution from the same web page:function! SetExecutableBit()  let fname = expand(%:p)  checktime  execute au FileChangedShell  . fname .  :echo  silent !chmod a+x %  checktime  execute au! FileChangedShell  . fnameendfunctioncommand! Xbit call SetExecutableBit()which makes it so I can use :Xbit within vim to add the x bit. This does add the x bit successfully, but whether or not I have syntax errors, it completely clears my terminal screen (line numbers included) except for my cursor and the vim command line on the bottom.
Glitch with auto chmod line in .vimrc
vim;vimrc