No Vimdiff, como alterno os painéis esquerdo e direito?


22

Quando eu faço vimdiff file2 file1, file2naturalmente vai à esquerda e file1à direita.

Às vezes, acho que as coloco de maneira errada, então gostaria de poder trocá-las sem sair do Vim. Isso é possível?

Respostas:


23

Você pode usar Ctrlw- x. De :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

Como você alternaria qualquer outra janela, <c-w>xou <c-w>rexistem duas opções.

Ter apenas duas janelas abertas <c-w>kirá trocá-las e deixar o cursor na janela onde estava antes da troca (ou seja, se antes da troca a janela focada estiver à esquerda, depois da troca estará à esquerda).

<c-w>x alternará as janelas e moverá o cursor na janela comutada (ou seja, a janela focada permanecerá à esquerda se estiver à esquerda).

Veja :help window-movingpara obter mais comandos para mover as janelas em voz alta.


4

Acho os seguintes comandos muito mais intuitivos que 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}

Esses comandos podem alterar o tamanho da janela, no entanto, esteja ciente disso.

Ao utilizar nosso site, você reconhece que leu e compreendeu nossa Política de Cookies e nossa Política de Privacidade.
Licensed under cc by-sa 3.0 with attribution required.