使用Ctrl-W_W跳过VIM中的窗口 [英] Skipping a window in VIM with Ctrl-W_W

查看:100
本文介绍了使用Ctrl-W_W跳过VIM中的窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在VIM中打开多个窗口时,每当我按Ctrl-W_W时,我总是希望跳过其中一个窗口(一个包含使用Aric Blumer的Project插件的项目的窗口).

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

换句话说,我想循环浏览文档窗口,就好像项目"窗口不是其中之一.当我确实确实想进入项目窗口时,我将使用为此目的专门创建的映射.

In other words I'd like to cycle through my document windows as if the Project window wasn't one of them. When I actually do want to go into the project window, I'll use the mapping I created especially for this purpose.

有没有一种标记窗口的方法,以便被Ctrl-W_W跳过,或者我需要脚本吗?我爱Vim,但仍然处于学习曲线的低谷.

Is there a way to mark a window so that it's skipped by Ctrl-W_W or would I need a script? I'm loving Vim but am still in the steep part of the learning curve.

推荐答案

您将必须编写一个循环到下一个窗口的函数(更易于维护),如果该函数与您所输入窗口的名称匹配,则将其跳过不想参加.

You would have to write a function (it's easier to maintain) that cycles to the next window, and skip it if it matches the name of the windows you don't want to go into.

类似的东西:

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>

这篇关于使用Ctrl-W_W跳过VIM中的窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆