Jak w Vimdiff przełączać lewe i prawe panele?


22

Kiedy to robię vimdiff file2 file1, file2naturalnie idzie po lewej i file1po prawej stronie.

Czasami okazuje się, że układam je w niewłaściwy sposób, więc chciałbym móc je zmieniać bez opuszczania Vima. Czy to jest możliwe?

Odpowiedzi:


23

Możesz użyć Ctrlw- x. Od :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

Podobnie jak w przypadku każdego innego okna <c-w>xlub <c-w>ristnieją dwie opcje.

Po wybraniu tylko dwóch okien zmieni <c-w>kje i pozostawi kursor w oknie, w którym znajdował się przed przełącznikiem (tj. Jeśli przed przełącznikiem skoncentrowane okno znajduje się po lewej stronie, po przełączniku będzie po lewej).

<c-w>x przełącza okna i przesuwa kursor w oknie przełączanym (tzn. okno skupione pozostaje po lewej stronie, jeśli było po lewej).

Zobacz :help window-movingwięcej poleceń, aby przenieść okna na głos.


4

Uważam następujące polecenia o wiele bardziej intuicyjne niż 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}

Te polecenia mogą jednak zmienić rozmiar okna, więc należy o tym pamiętać.

Korzystając z naszej strony potwierdzasz, że przeczytałeś(-aś) i rozumiesz nasze zasady używania plików cookie i zasady ochrony prywatności.
Licensed under cc by-sa 3.0 with attribution required.