tags:

views:

45

answers:

1

I have a windows directory (U:\S) that contains files that must not be changed. Their read-only bit cannot be set, so they must remain writeable.

As I have to look into some of the file's content rather regurarly with VIM, I want to make sure that I don't accidentally change the file's conent.

So, I put the following line into my .vimrc conifugration file:

autocmd InsertEnter u:/s/* call confirm("File should not be changed")

which seemed to work fine.

But then, I have also directory named U:\supportTerminal that contains files that I have to change. When I edit a file within that directory, the file pattern u:/s/* for some reason matches and my warning pops up.

I tried playing around with some pattern, but I found none that only matches within u:\s but not within u:\supportTerminal

So, how could I go about what I want?

+2  A: 

That makes for a bug, which you should report to vim-dev at vim.org. In linux I don't have this behaviour: it matches nicely.

As a temporary workaround,

:au BufRead u:/s/* set readonly
:au! BufRead u:/supportTerminal/* 

should first make the general rule and then remove the one dir as an exception. Not sure whether this works in Windows GVim properly. Should this fail, other hack would be:

:au BufRead u:/supportTerminal/* set noreadonly

PS: As mentioned in the comments above, setting vim's own setting readonly works better to prevent accidental edits. User can't :write files with RO flag on, but it can be circumvented by setting noreadonly if needed.

progo