> When I edit a new .sh file, I always want to 'chmod +x'. I'm wondering
> if there is a way to make this process automated in vim?
>
Apparently there is a getfperm() function, but no setfperm() so all I
can think of is
if has('autocmd')
au BufNewFile *.sh
\ if has('unix')
\ | w
\ | exe '!chmod a+x %'
\ | endif
endif
The ":w" command makes sure that the file exists before we try to set
its permissions.
This is not perfect: Vim will probably complain that the file was
modified outside of Vim (when we changed its permissions by means of an
external command). See
:help FileChangedShell
:help v:fcs_reason
Best regards,
Tony.
--
If you want to understand your government, don't begin by reading the
Constitution. It conveys precious little of the flavor of today's
statecraft. Instead, read selected portions of the Washington
telephone directory containing listings for all the organizations with
titles beginning with the word "National".
-- George Will
--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
No comments:
Post a Comment