Seems that :windo
leaves my cursor in the bottom window.
How can I get it to return to the window and cursor-position I was at before I ran :windo
?
I thought mZ
, then `Z
would work. But it just brings that file into the bottom window, instead of moving me back to where I was.
Running 7.3.462 on Win XP.
Thanks
You could save buffer and view:
let saved_bufnr = bufnr("%")
let saved_view = winsaveview()
and use it to restore the exact position (after argdo
, bufo
, windo
, tabdo
, global
or any combination of those)
exec 'buffer ' . saved_bufnr
call winrestview(saved_view)
Note This effectively uses the plumbing that underlies the standard :mkview
, :mksession
functionality too. If you really wanted to restore all windows/tabs, by all means just use
:mksession! /tmp/tmpsession.vim
:# do the work
:source /tmp/tmpsession.vim
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With