如何在vim中翻转窗口?

发布于 2024-11-08 15:42:11 字数 273 浏览 0 评论 0原文

可能的重复:
要快速从垂直分割切换到水平分割维姆

如果我有 2 个水平分割的窗口,如何旋转它们以获得 2 个垂直分割的窗口?

以及如何切换缓冲区?

Possible Duplicate:
To switch from vertical split to horizontal split fast in Vim

If I have 2 horizontally split windows, how to rotate them to get 2 vertically split windows?

And how to switch buffers?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

心凉 2024-11-15 15:42:11

如果您将它们垂直拆分 CwJ 将其中一个移动到底部

如果您将它们水平拆分 CwL向右移动

要在分割窗口的“列”或“行”中旋转,CwCr

以下命令可用于更改窗口布局。例如,
当有两个垂直分割的窗口时,CTRL-W K 将更改
水平分割窗口。 CTRL-W H 则相反。

If you have them split vertically C-wJ to move one to the bottom

If you have them split horizontally C-wL to move one to the right

To rotate in a 'column' or 'row' of split windows, C-wC-r

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.

自控 2024-11-15 15:42:11

Ctrl-w H 或输入 :wincmd H水平布局变为垂直布局。

Ctrl-w J 或输入 :wincmd J垂直到水平布局。

Ctrl-w r 或输入 :wincmd r交换两个缓冲区,但保持窗口布局相同。

Ctrl-w w 或输入 :wincmd w 在两个窗口/缓冲区之间移动光标

您可能希望绑定这些序列中的一个或多个以加快键入速度。我将其放入 .vimrc 中,以便 ,l 将光标移动到当前选项卡中的下一个缓冲区:

let mapleader = ","
nmap <Leader>l <C-w>w

Ctrl-w H or type :wincmd H to go from horizontal to vertical layout.

Ctrl-w J or type :wincmd J to go from vertical to horizontal layout.

Ctrl-w r or type :wincmd r to swap the two buffers but keep the window layout the same.

Ctrl-w w or type :wincmd w to move the cursor between the two windows/buffers.

You may wish to bind one or more of these sequences to make it faster to type. I put this in my .vimrc so that ,l moves the cursor to the next buffer in the current tab:

let mapleader = ","
nmap <Leader>l <C-w>w
乙白 2024-11-15 15:42:11

CTRL-W SHIFT-H 将旋转方向,CTRL-W H 移动到左侧窗口,CTRL-W L 向右移动。请参阅

:help split

:help ^w

了解更多信息。

CTRL-W SHIFT-H will rotate the orientation, CTRL-W H moves to the left window, CTRL-W L moves to the right. See

:help split

and

:help ^w

for more information.

如果您只打开两个窗口,当前的答案都非常有效。如果你有更多的东西,移动窗口的逻辑就会变得很复杂。

我的 .vimrc 中有这个,允许我“猛拉”和“删除”缓冲区,然后将其粘贴到当前缓冲区上方的窗口中或作为 [v] 分割。

fu! PasteWindow(direction) "{{{
    if exists("g:yanked_buffer")
        if a:direction == 'edit'
            let temp_buffer = bufnr('%')
        endif

        exec a:direction . " +buffer" . g:yanked_buffer

        if a:direction == 'edit'
            let g:yanked_buffer = temp_buffer
        endif
    endif
endf "}}}

"yank/paste buffers
:nmap <silent> <leader>wy  :let g:yanked_buffer=bufnr('%')<cr>
:nmap <silent> <leader>wd  :let g:yanked_buffer=bufnr('%')<cr>:q<cr>
:nmap <silent> <leader>wp :call PasteWindow('edit')<cr>
:nmap <silent> <leader>ws :call PasteWindow('split')<cr>
:nmap <silent> <leader>wv :call PasteWindow('vsplit')<cr>
:nmap <silent> <leader>wt :call PasteWindow('tabnew')<cr>

The current answers all work great if you only have two windows open. If you have more than that, the logic for moving windows around can get hairy.

I have this in my .vimrc to allow me to 'yank' and 'delete' a buffer and then paste it into a window over the current buffer or as a [v]split.

fu! PasteWindow(direction) "{{{
    if exists("g:yanked_buffer")
        if a:direction == 'edit'
            let temp_buffer = bufnr('%')
        endif

        exec a:direction . " +buffer" . g:yanked_buffer

        if a:direction == 'edit'
            let g:yanked_buffer = temp_buffer
        endif
    endif
endf "}}}

"yank/paste buffers
:nmap <silent> <leader>wy  :let g:yanked_buffer=bufnr('%')<cr>
:nmap <silent> <leader>wd  :let g:yanked_buffer=bufnr('%')<cr>:q<cr>
:nmap <silent> <leader>wp :call PasteWindow('edit')<cr>
:nmap <silent> <leader>ws :call PasteWindow('split')<cr>
:nmap <silent> <leader>wv :call PasteWindow('vsplit')<cr>
:nmap <silent> <leader>wt :call PasteWindow('tabnew')<cr>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文