Thursday, October 7, 2010

Re: indexing an undo "state"

On Thu, 7 Oct 2010, Eric Smith wrote:

> Hi
>
> How may I index or name a specific state of the buffer in order to
> return to it later?

If you mean a specific 'undo' state:

" save position
let b:saved_state = undotree()['seq_last']

" go to it

" - save the current position, to be able to go back to it
let b:just_in_case = undotree()['seq_last']

" - go to the saved position
exe "undo ".b:saved_state

" - not what you wanted?
exe "undo ".b:just_in_case

:help undotree()
:help :undo

If you mean a specific window layout:

" save the view
let g:window_layout = winsaveview()

" restore it
call winrestview(g:window_layout)

:help winsaveview()
:help winrestview()


Or a whole editing session (saves lots of stuff), but not generally file
states:

" make a session
:mksession filename

:help :mksession

--
Best,
Ben

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: