Wikia

Vim Tips Wiki

Changes: Switching between files

Edit

Back to page

(Remove html character entities)
(Link to "Easier buffer switching" page)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{review}}
 
 
{{TipImported
 
{{TipImported
 
|id=195
 
|id=195
 
|previous=194
 
|previous=194
 
|next=196
 
|next=196
|created=January 9, 2002
+
|created=2002
 
|complexity=basic
 
|complexity=basic
 
|author=Kontra, Gergely
 
|author=Kontra, Gergely
|version=5.7
+
|version=6.0
 
|rating=43/26
 
|rating=43/26
|category1=
+
|category1=Navigation
 
|category2=
 
|category2=
 
}}
 
}}
When you edit multiple files, you often need to change windows.
+
When editing multiple files, it is often necessary to switch from one file to another. That can be done more easily using a mapping, rather than entering a command. This tip maps Ctrl-Tab and Ctrl-Shift-Tab to move forwards or backwards through the available buffers or windows.
   
You can set up Vim in windows and gvim to switch between windows with the commonly used Ctrl-Tab and Ctrl-Shift-Tab
+
If you prefer to work with buffers, you can map the <code>:bn</code> and <code>:bp</code> commands (buffer next, and buffer previous).
  +
<pre>
  +
nnoremap <C-Tab> :bn<CR>
  +
nnoremap <C-S-Tab> :bp<CR>
  +
</pre>
   
The mappings
+
If you frequently use split windows, you might want to use the Ctrl-W family of commands to switch between windows.
  +
<pre>
  +
nnoremap <C-Tab> <C-w>w
  +
nnoremap <C-S-Tab> <C-w>W
  +
</pre>
   
  +
And if you prefer one tab for one buffer, you can map the <code>:tabn</code> and <code>:tabp</code> commands (tab next, and tab previous).
 
<pre>
 
<pre>
nmap <C-Tab> <C-w>w
+
nnoremap <C-Tab> :tabn<CR>
nmap <C-S-Tab><C-w>W
+
nnoremap <C-S-Tab> :tabp<CR>
 
</pre>
 
</pre>
 
They wrap around.
 
   
 
==References==
 
==References==
  +
*[[Easier_buffer_switching]] - I highly recommend the <code><F5></code> mapping followed by completion with <code><Ctrl-N></code> or <code><Tab></code>.
 
*{{help|CTRL-W}}
 
*{{help|CTRL-W}}
  +
*{{help|:bnext}}
  +
*{{help|:bprevious}}
  +
*{{help|:tabnext}}
  +
*{{help|:tabprevious}}
   
 
==Comments==
 
==Comments==
I don't know which way is better, but I couldn't get that way to work. So I use this instead.
 
 
<pre>
 
:map <C-Tab> :bn<CR>
 
:map <C-S-Tab> :bp<CR>
 
</pre>
 
 
----
 

Latest revision as of 21:04, August 29, 2013

Tip 195 Printable Monobook Previous Next

created 2002 · complexity basic · author Kontra, Gergely · version 6.0


When editing multiple files, it is often necessary to switch from one file to another. That can be done more easily using a mapping, rather than entering a command. This tip maps Ctrl-Tab and Ctrl-Shift-Tab to move forwards or backwards through the available buffers or windows.

If you prefer to work with buffers, you can map the :bn and :bp commands (buffer next, and buffer previous).

nnoremap <C-Tab> :bn<CR>
nnoremap <C-S-Tab> :bp<CR>

If you frequently use split windows, you might want to use the Ctrl-W family of commands to switch between windows.

nnoremap <C-Tab> <C-w>w
nnoremap <C-S-Tab> <C-w>W

And if you prefer one tab for one buffer, you can map the :tabn and :tabp commands (tab next, and tab previous).

nnoremap <C-Tab> :tabn<CR>
nnoremap <C-S-Tab> :tabp<CR>

ReferencesEdit

CommentsEdit

Around Wikia's network

Random Wiki