Plotting vertical asymptotes

It is often advantageous to plot vertical asymptotes as distinct from the plotted function. The function AsymptotePlot has the same form as most plot functions, but the third argument is a list of the locations of the vertical asymptotes. There is also a new option AsymptoteStyle which takes any values you can use with lines such as Thickness, Hue, RGBColor  and Dashing.

The function

AsymptotePlot[func1_,{var_,varmin_,varmax_},asymptotes_?ListQ,opts___?OptionQ] := Module[{func,plt1,selectlist},
pltopts = Select[{opts},#[[1]]=!= AsymptoteStyle&];
asymp = AsymptoteStyle/.{opts}/.AsymptoteStyle -> AbsoluteDashing[{4,8}];
func=If[Head[func1]===Symbol,func1[var],func1];
plt1 = Plot[func,{var,varmin,varmax},DisplayFunction -> Identity,Evaluate[pltopts]];
plt1a = plt1[[1,1,1,1]];
selectlist= Partition[Sort[Flatten[Append[{varmin,varmax},asymptotes]]],2,1];
lns = Map[Line,Table[Select[plt1a,(selectlist[[i,1]]≤#[[1]]≤selectlist[[i,2]]&)],{i,Length[selectlist]}]];
rngvals = AbsoluteOptions[plt1,PlotRange][[1,2,2]];
asymps =  Flatten[{asymp,Map[Line[{Prepend[{rngvals[[1]]},#],Prepend[{rngvals[[2]]},#]}]&,asymptotes]}];
theplt = Show[Graphics[{lns,asymps},Axes -> True],pltopts]
]

Some examples

AsymptotePlot[(((x^2)+ 2)/((x-1)(x + 1))),{x,-2,3},{-1,1},AspectRatio -> 1]

The same plot with color added to the asymptotes.

AsymptotePlot[(((x^2)+ 2)/((x-1)(x + 1))),{x,-2,3},{-1,1},AspectRatio -> 1,AsymptoteStyle -> {Hue[.95],AbsoluteDashing[{8,8}]}]

Here is another example with blue asymptotes and no dashing.

f2[x_] := ((3 (x^2)+ 2x - 7)/((x^(2 ))- x -2))

AsymptotePlot[f2[x],{x,-3,3},{-1,2},AsymptoteStyle -> Hue[.7]]