在Vimdiff中,如何切换左右窗格?


22

当我这样做时vimdiff file2 file1file2自然会在左侧和file1右侧。

有时我发现我把它们弄错了方向,所以我希望能够在不离开Vim的情况下进行切换。那可能吗?

Answers:


23

您可以使用Ctrlw- x。来自:he CTRL-W_x

CTRL-W x                                            CTRL-W_x CTRL-W_CTRL-X
CTRL-W CTRL-X   Without count: Exchange current window with next one.  If there
                is no next window, exchange with previous window.
                With count: Exchange current window with Nth window (first
                window is 1).  The cursor is put in the other window.
                When vertical and horizontal window splits are mixed, the
                exchange is only done in the row or column of windows that the
                current window is in.

11

正如您将切换任何其他窗口一样,<c-w>x还是<c-w>r两个选项。

<c-w>k打开两个窗口将切换它们,并将光标留在切换之前的窗口中(即,如果在切换之前,聚焦窗口在左侧,则在切换之后,它将在左侧)。

<c-w>x 将切换窗口并在切换的窗口中移动光标(即,如果焦点位于左侧,则聚焦窗口保持在左侧)。

请参阅:help window-moving以获取更多命令来移动窗口。


4

我发现以下命令比Ctrlw- 更直观x

:help CTRL-W_K

The following commands can be used to change the window layout.  For example,
when there are two vertically split windows, CTRL-W K will change that in
horizontally split windows.  CTRL-W H does it the other way around.

                        *CTRL-W_K*
CTRL-W K    Move the current window to be at the very top, using the full
        width of the screen.  This works like closing the current
        window and then creating another one with ":topleft split",
        except that the current window contents is used for the new
        window.

                        *CTRL-W_J*
CTRL-W J    Move the current window to be at the very bottom, using the
        full width of the screen.  This works like closing the current
        window and then creating another one with ":botright split",
        except that the current window contents is used for the new
        window.

                        *CTRL-W_H*
CTRL-W H    Move the current window to be at the far left, using the
        full height of the screen.  This works like closing the
        current window and then creating another one with
        ":vert topleft split", except that the current window contents
        is used for the new window.
        {not available when compiled without the |+vertsplit| feature}

                        *CTRL-W_L*
CTRL-W L    Move the current window to be at the far right, using the full
        height of the screen.  This works like closing the
        current window and then creating another one with
        ":vert botright split", except that the current window
        contents is used for the new window.
        {not available when compiled without the |+vertsplit| feature}

这些命令可以更改窗口的大小,但是请注意这一点。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.