+" needed function preserve to avoid `"
+" this function can be used for many other things like reload vimrc withou moving the cursor
+" or reindent the current buffer keeping the cursor position
+" Utility function that save last search and cursor position
+" http://technotales.wordpress.com/2010/03/31/preserve-a-vim-function-that-keeps-your-state/
+" video from vimcasts.org: http://vimcasts.org/episodes/tidying-whitespace
+" using 'execute' command doesn't overwrite the last search pattern, so I
+" don't need to store and restore it.
+ function! Preserve(command)
+ let l:win_view = winsaveview()
+ "silent! keepjumps keeppatterns execute a:command
+ silent! execute 'keeppatterns keepjumps ' . a:command
+ call winrestview(l:win_view)
+command! BufOnly silent! call Preserve("exec '%bd|e#|bd#'")