Di Vimdiff, bagaimana cara mengganti panel kiri dan kanan?


22

Ketika saya melakukannya vimdiff file2 file1, file2secara alami berjalan ke kiri dan file1ke kanan.

Kadang-kadang saya menemukan bahwa saya menempatkan mereka dengan cara yang salah, jadi saya ingin dapat mengubahnya tanpa meninggalkan Vim. Apakah itu mungkin?

Jawaban:


23

Anda dapat menggunakan Ctrlw- x. Dari :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

Seperti Anda akan beralih jendela lain, <c-w>xatau <c-w>rdua opsi.

Jika hanya dua jendela yang terbuka <c-w>kakan beralih dan meninggalkan kursor di jendela di mana sebelum sakelar (yaitu jika sebelum sakelar jendela fokus ada di sebelah kiri, setelah sakelar itu akan di sebelah kiri).

<c-w>x akan mengalihkan jendela dan memindahkan kursor di jendela yang diaktifkan (yaitu, jendela fokus tetap di sebelah kiri jika di sebelah kiri).

Lihat :help window-movingperintah lainnya untuk memindahkan windows dengan keras.


4

Saya menemukan perintah berikut jauh lebih intuitif daripada 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}

Namun, perintah ini dapat mengubah ukuran jendela, jadi waspadalah.

Dengan menggunakan situs kami, Anda mengakui telah membaca dan memahami Kebijakan Cookie dan Kebijakan Privasi kami.
Licensed under cc by-sa 3.0 with attribution required.