" 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" preserve function" 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.if!exists('*Preserve')function! Preserve(command)tryletl:win_view = winsaveview() "silent! keepjumps keeppatterns execute a:commandsilent! execute 'keeppatterns keepjumps ' . a:command
finallycall winrestview(l:win_view)endtryendfunctionendifcommand! BufOnly silent!call Preserve("exec '%bd|e#|bd#'")cab bo BufOnly
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.