I have some Vim functions that make changes to the document format. When I call this function, I currently use something like the following to save and restore my cursor positio
let l:winview = winsaveview()
" do stuff
call winrestview(l:winview)
This should pretty much do exactly what you want it to do, possibly excepting the line count changing above the cursor (I suspect that deleted lines above the cursor would have the effect of moving the cursor down).