" from http://vimcasts.org/episodes/tidying-whitespace/
function! Preserve(command)
  " Preparation: save last search, and cursor position.
  let _s=@/
  let save_cursor = getpos('.')
  " Do the business:
  execute a:command
  " Clean up: restore previous search history, and cursor position
  let @/=_s
  call setpos('.', save_cursor)
endfunction

" from http://vimcasts.org/episodes/tidying-whitespace/
function! Preserve(command)
  " Preparation: save last search, and cursor position.
  let save_cursor = getpos('.')
  let last_search = getreg('/')
  " Do the business:
  execute a:command
  " Clean up: restore previous search history, and cursor position
  call setpos('.', save_cursor)
  call setreg('/', last_search)
endfunction

Refactor Preserve function based on Mathias Bynens
Refactor Preserve function based on Mathias Bynens

https://github.com/mathiasbynens/dotfiles/blob/master/.vimrc

dougireton/mirror_pond