What is the correct way to make git ignore temporary files produced by vim in all directories (either globally across the system or locally for a single project)?
If You are using source control. vim temp files are quite useless. So You might want to configure vim not to create them.
Just edit Your ~/.vimrc and add these lines:
set nobackup set noswapfile