Let $\mathbb P^n=\mathbb {CP^n}$, I guess the following is true:
Let $D\subset \mathbb P^n$ be a closed subscheme of codimension $2$. Then every automorphism of $\mathbb P^n-D$ is linear, i.e. ${\rm Aut}(\mathbb P^n-D)\subset {\rm Aut}(\mathbb P^n)$.
More generally, I guess the following is also true:
Let $D\subset V$ be a closed subscheme of codimension $2$, here $V$ is an arbitrary variety. Then ${\rm Aut}(V-D)\subset {\rm Aut}(V)$.
Is it correct? Could someone give a reference or counter example about this?
I think the codimension $2$ condition is for Hartog's theorem, but I do not know how to apply it. Clearly we can not expect any morphism to extend to $D$, as there may be base locus, so we really need automorphisms. Also, it is not enough if $D$ is of codimension $1$, since there is trivial counter-example $\mathbb P^n-D=\mathbb A^n$.