Last active
December 17, 2015 19:39
-
-
Save kshenoy/5661853 to your computer and use it in GitHub Desktop.
Function to execute commands without modifying the original settings like cursor position, search string etc.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function! Preserve( command ) | |
" Description: Function to execute commands without modifying the original settings like cursor position, search string etc. | |
" Save last search, and cursor position. | |
let currview = winsaveview() | |
" Do the business | |
silent! execute a:command | |
" Restore previous search history, and cursor position | |
call winrestview( currview ) | |
endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment