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?
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,
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:
PS: As mentioned in the comments above, setting vim’s own setting
readonlyworks better to prevent accidental edits. User can’t:writefiles with RO flag on, but it can be circumvented by settingnoreadonlyif needed.