zhuang@linux:~/reading/practical-vim/06-manage-multiple-files/$ less
Manage Multiple Files
This post extracts some knowledge from Chapter 6 – Manage Multiple Files.
traverse the buffer list:
vim
:bn
:bp
:bf
:bl
:b N
:b bufnamedelete buffer(just close buffer not real delete associated file):
vim
:bdelete N1 N2 N3
:N,M bdeletevim
:next
:prev
:first
:last
:args **/*.js **/*.css
:argdo| 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 |
| 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.
zhuang@linux:~/reading/practical-vim/06-manage-multiple-files/$ comments