Skipping a window in VIM with Ctrl-W_W

When I have several windows open in VIM, I would like to always skip one of them (the one that contains my project using the Aric Blumer Project plugin), whenever I press Ctrl-W_W.

In other words, I would like to iterate over the document windows, as if the project window was not one of them. When I really want to enter the project window, I use a mapping specially created for this purpose.

Is there a way to mark the window so that it skips Ctrl-W_W or will I need a script? I love Vim, but still in the steepest part of the learning curve.

+3
source share
1 answer

( ), , , , .

- :

function! s:NextWindowBut(skip,dir)
  let w0 = winnr()
  let nok = 1
  while nok
    " exe "normal! \<c-W>w"
    " or better
    exe 'wincmd '.a:dir
    let w = winnr()
    let n = bufname('%')
    let nok = (n=~a:skip) && (w != w0)
    " echo "skip(".n."):".(n=~a:skip)." w!=w0:".(w != w0)." --> ".nok
  endwhile
  if w == w0
    echomsg "No other acceptable window"
  endif
endfunction

nnoremap <silent> <C-W>w :call <sid>NextWindowBut('thepattern','w')<cr>
nnoremap <silent> <C-W>W :call <sid>NextWindowBut('thepattern','W')<cr>
+6

Source: https://habr.com/ru/post/1770663/


All Articles