> Is there a way to set a umask value in vim so that execute permission is added to a file on its creation, by default?

Is there a way to set a umask value in vim so that execute permission is added to a file on its creation, by default?

Posted at: 2014-12-18 
How do you make a file executable?

No, umask will not help. The umask value only turns off selected permission bits. It will not turn on anything.

A quick web search shows that there's a user-contributed vim plugin at vim.org that does what you want, at:

http://www.vim.org/scripts/script.php?sc...

What I see is a small plugin script, dated 9/1/2006, that's been downloaded 396 times in 8 years. Maybe this is an indication that automatically adding the X bit isn't considered a Real Good Idea?

If I was doing a lot of bash script editing, I might make my own script ("vx" sounds like a good name) that ran vim on the argument file name and then ran a chmod on the name. Something like:

#!/bin/bash

vim &1

chmod a+x &1

In the second version of the script, I'd add code to check that the file exists afterward and either didn't exist before or had an older timestamp. (...if I felt I needed that 2nd version.) (Probably, I'd have added some argument verification and a usage display too.)

Anyway, the idea is that I knew when I typed the command that I wanted to make the result executable

How do you make a file executable?