Is there any setting for vim create new files with full permissions? that is falling just under the umask restrictions, and only on files created by vim. It shouldn't modify the bits of an already existing file. I've already seen the solution that sets the x bit on for files in /bin/ or starting by #!, but I'd like my vim to obey umask, and umask only.

1 Answer 1


This has been asked before in various places. In short, vim uses umask only (like other applications) to turn off permissions, but you can use a script to modify file permissions.

Most applications (such as text editors) treat their output as data, and when opening (creating) a file, use data-style permissions, e.g., 0666, 0644, 0600, etc. Likewise, most programs do not set umask themselves, but merely rely upon existing settings to reduce privileges which they might offer to some users.

Opening an existing file is a different matter. Many editors write the updated file without recreating or renaming it, using the same inode. This happens to preserve the permissions (and ownership) of a file. A few (e.g., vim and vile) have some provision for temporarily changing a file's permissions to write on a "read-only" file. For that, they have to know what the original permissions were, but again umask is irrelevant to the resulting file permissions.

For further reading

  • But it doesn't. with an umask of 0022, or even 0, files are not created executable, the permissions are indeed restricted by the umask, but vim never creates them executable. touch, for example, does
    – Alex
    Oct 12, 2015 at 12:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.