Results 1 to 2 of 2
I am trying to configure vim so that when I write a new script it will automatically set the executable bit on it when I write to it for the ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 10-27-2011 #1Just Joined!
- Join Date
- Mar 2011
- Posts
- 67
how do I configure vim to set the executable bit on scripts?
I am trying to configure vim so that when I write a new script it will automatically set the executable bit on it when I write to it for the first time without the annoying
No matter what I do though, it doesn't seem to work.Code:W16: Warning: Mode of file "b.sh" has changed since editing started See ":help W16" for more info. [O]K, (L)oad File:
here is my .vimrc:
and this is my .vim/mod.vim file:Code:so ~/.vim/mod.vim autocmd BufNewFile * let fname=expand("%:p") autocmd BufNewFile *.pl execute "autocmd BufWritePost ".fname." call SetExecutableBit()" autocmd BufNewFile *.sh execute "autocmd BufWritePost ".fname." call SetExecutableBit()" autocmd BufNewFile *.rb execute "autocmd BufWritePost ".fname." call SetExecutableBit()" autocmd BufNewFile *.py execute "autocmd BufWritePost ".fname." call SetExecutableBit()"
Code:function! SetExecutableBit() let fname=expand("%:p") execute "autocmd FileChangedShell ".fname execute "!chmod a+x ".fname execute "autocmd! FileChangedShell ".fname endfunction
- 10-28-2011 #2Just Joined!
- Join Date
- Mar 2011
- Posts
- 67
nevermind I figured it out. it turns out I have to change it from "BufWritePost" to "BufWrite"


Reply With Quote
