Manage Multiple Files

This post extracts some knowledge from Practical Vim Chapter 6 -- Manage Multiple Files.

[!TIP] Track Open Files with the Buffer List

traverse the buffer list:

:bn
:bp
:bf
:bl
:b N
:b bufname

delete buffer(just close buffer not real delete associated file):

:bdelete N1 N2 N3
:N,M bdelete

[!TIP] Group Buffers into a Collection with the Argument List

:next
:prev
:first
:last
:args **/*.js **/*.css
:argdo

[!TIP] Divide Your Workspace into Split Windows

Command Effect
<C-w>s Split the current window horizontally, reusing the current buffer in the new window
<C-w>v Split the current window vertically, reusing the current buffer in the new window
:sp[lit] {file} Split the current window horizontally, loading {file} into the new window
:vsp[lit] {file} Split the current window vertically, loading {file} into the new window

Changing the Focus Between Windows

Command Effect
<C-w>w Cycle between open windows
<C-w>h Focus the window to the left
<C-w>j Focus the window below
<C-w>k Focus the window above
<C-w>l Focus the window to the right

Closing Windows | Ex Command | Normal Command | Effect | |------------|----------------|---------| | :clo[se] | <C-w>c | Close the active window | | :on[ly] | <C-w>o | Keep only the active window, closing all others |

Resizing and Rearranging Windows | Keystrokes | Effect | |------------|---------| | <C-w>= | Equalize width and height of all windows | | <C-w>_ | Maximize height of the active window | | <C-w>\| | Maximize width of the active window | | [N]<C-w>_ | Set active window height to [N] rows | | [N]<C-w>\| | Set active window width to [N] columns |

more details

[!TIP] Organize Your Window Layouts with Tab Pages

Command Effect
:tabe[dit] {filename} Open {filename} in a new tab
<C-w>T Move the current window into its own tab
:tabc[lose] Close the current tab page and all of its windows
:tabo[nly] Keep the active tab page, closing all others

Switching Between Tabs

Ex Command Normal Command Effect
:tabn[ext] {N} {N}gt Switch to tab page number {N}
:tabn[ext] gt Switch to the next tab page
:tabp[revious] gT Switch to the previous tab page

Rearranging Tabs We can use the :tabmove [N] Ex command to rearrange tab pages. When [N] is 0, the current tab page is moved to the beginning, and if we omit [N], the current tab page is moved to the end.


原文链接:https://zhuang.dev/reading/practical-vim/06-manage-multiple-files/

posted @ 2026-07-12 22:50  neozhuang  阅读(17)  评论(0)    收藏  举报