On Wed, Nov 28, 2012 at 9:09 AM, Marcin Szamotulski <mszamot@gmail.com> wrote:
Hello,
I really like the command CTRL-Wp to jump to the previous window. In
one of me plugins I jump to another window and come back. This
unfortunately destroys the CTRL-Wp. How to make it work (except of
going through the window that CTRL-Wp points to and coming back through
it). There is keepjumps and keepalt modifiers, I haven't seen something
like this for windows. Any ideas?
Best,
Marcin
--
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
I do this:
let t:lastWindow = winnr()
" When changing tabs, the WinLeave also gets called, changing the last window to what is actually the current window. So, we store the previous last window in
" the WinLeave autocommand and, if the WinLeave was the result of a TabLeave, restore it in the TabLeave.
augroup LastTab
au!
au TabLeave * let t:lastWindow = t:oldLastWindow
au WinLeave * let t:oldLastWindow = t:lastWindow | let t:lastWindow = winnr()
au TabEnter * if ( !exists( "t:lastWindow" ) ) | let t:lastWindow = winnr() | endif
augroup END
function! ToggleWindow( ... )
let windowNumber = exists( "a:1" ) ? a:1 : t:lastWindow
if ( windowNumber == winnr() )
let windowNumber = windowNumber - 1
endif
if ( windowNumber > winnr( '$' ) )
let windowNumber = 1
elseif ( windowNumber < 1 )
let windowNumber = winnr( '$' )
endif
execute windowNumber . 'wincmd w'
endfunction
You could then set a mapping or add a flag to the autocommand to NOT change the t:lastWindow and then set it before you move about.
I have a normal mode mapping to :call ToggleWindow()<CR>
Hope this helps,
Salman
--
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:
Post a Comment