I've seen set exrc mentioned in various places for using per-directory .vimrc files, but every time it's been mentioned it's been with strong admonition not to actually use it because it's dangerous. I've also come across set secure which is supposed to fix some of the inherit danger of set exrc, but even with that the consensus seems to be not to use set exrc. I've heard bits and pieces of why, but what exactly are the dangers of using set exrc, with or without set secure?
Why is set exrc dangerous?
vimrc
Because you're telling vim to perform some commands from a file you may not have control over or someone else could have written. Say you grab something from github, and deep in the tree there's a .vimrc. If you vim something in that directory and have set exrc, you're telling vim to run the commands in the .vimrc you got from github. Do you completely trust whoever created that file? Because you're letting vim run whatever commands they put in that file. Or say you're on a machine regularly used by multiple people (they still exist :-) ), and someone asks you to look at something in their home directory (or /tmp, or any place they can write to). You cd there, it's a text file, so you do a vim file. With set exrc, you're also telling vim to run the commands in .vimrc in that directory. Do you completely trust that user, or in a world writable directory like /tmp, every user who can log in to that machine?set secure mitigates the problem somewhat by limiting some things that can be done in a .vimrc, but if the per-directory .vimrc can made to be owned by you (such as in the github example, or on a multi-user machine where some users can chown files to you), set secure is ignored, so you still have the same problems.