Thursday, April 8, 2010

Re: switching to window, by buffer nr

On Thu, 8 Apr 2010, Ben Fritz wrote:
> On Apr 8, 9:20 am, "Christian Brabandt" wrote:
> > On Thu, April 8, 2010 4:14 pm, Ben Fritz wrote:
> > > On Apr 7, 3:16 pm, Christian Brabandt wrote:
> > >> exe "bufwinnr(1)" wincmd w
> >
> > > This will not work. wincmd w does the same thing as CTRL-W w,
> > > which will jump to a specific WINDOW, in top-to-bottom,
> > > left-to-right order. It does NOT jump to the window containing a
> > > specific BUFFER.
> >
> > Yes it does. There is even an example in the help.
> > See :h winc
> >
>
> From :help :winc :
>
> The count can also be a window number. Example:
> :exe nr . "wincmd w"
> This goes to window "nr".
>
> I assume this is the example to which you refer.
>
> Note the difference between WINDOW nr, and BUFFER nr.
>
> The OP may have a situation like this:
>
> +-------------------------------------+
> | | | |
> | Window 1 | Window 2 | Window 3 |
> | | | |
> | Buffer 2 | Buffer 4 | Buffer 1 |
> | | | |
> +-------------------------------------+
>
> Executing :2wincmd w will take you to Window 2, which is displaying
> Buffer 4. IIUC, the OP said he wants to jump to the window containing
> BUFFER 2 in this situation, which would be Window 1.

Which is why Christian wrote (correcting his misplaced quotes, as noted
in another branch of this thread):

exe bufwinnr(1) "wincmd w"

Using 2 instead of 1 in your example would work fine, as he claims:

exe bufwinnr(2) "wincmd w"

would execute "1wincmd w"

--
Best,
Ben H

--
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

To unsubscribe, reply using "remove me" as the subject.

No comments: