Thursday, December 3, 2009

Re: How to change the mode for a new file automatically?

* Peng Yu <pengyu.ut@gmail.com> 02.12.2009

> 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?

Hello Peng,

I have this in my vimrc.
--------------------------------+
function ModeChange() |
if getline(1) =~ "^#!" |
if getline(1) =~ "/bin/" |
silent !chmod a+x <afile> |
endif |
endif |
endfunction |
--------------------------------+
Hth Michael

--
24 hours in a day, 24 beers in a case. Coincidence?

No comments: