Wikia

Vim Tips Wiki

Changes: Switching between files

Edit

Back to page

(Remove html character entities)
Line 1: Line 1:
{{review}}
+
When you edit multiple files, you often need to change between files. It quickly become tedious that you have to strain your fingers to Escape then go to command mode and enter one of related commands to switch to another file.
{{TipImported
 
|id=195
 
|previous=194
 
|next=196
 
|created=January 9, 2002
 
|complexity=basic
 
|author=Kontra, Gergely
 
|version=5.7
 
|rating=43/26
 
|category1=
 
|category2=
 
}}
 
When you edit multiple files, you often need to change windows.
 
   
You can set up Vim in windows and gvim to switch between windows with the commonly used Ctrl-Tab and Ctrl-Shift-Tab
+
You can set up Vim in windows and gvim to switch between files with the commonly used Ctrl-Tab and Ctrl-Shift-Tab
   
The mappings
+
This depends on how do you normally work.
   
  +
# If you prefer to work with just buffers (ie., whole screen dedicated to one buffer): you can map :bn and :bp commands.
 
<pre>
 
<pre>
nmap <C-Tab> <C-w>w
+
nnoremap <C-Tab> :bn
nmap <C-S-Tab><C-w>W
+
nnoremap <C-S-Tab> :bp
  +
</pre>
  +
# If you rather use split windows all the time, you rather use 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 are one of those who prefer one tab for one buffer guy, you can map :tabn and :tabp commands.
  +
<pre>
  +
nnoremap <C-Tab> :tabn
  +
nnoremap <C-S-Tab> :tabp
 
</pre>
 
</pre>
   
They wrap around.
 
   
 
==References==
 
==References==
*{{help|CTRL-W}}
+
*{{help|CTRL-W}}
+
*{{help|:bnext}}
==Comments==
+
*{{help|:bprevious}}
I don't know which way is better, but I couldn't get that way to work. So I use this instead.
+
*{{help|:tabnext}}
+
*{{help|:tabprevious}}
<pre>
 
:map <C-Tab> :bn<CR>
 
:map <C-S-Tab> :bp<CR>
 
</pre>
 
   
 
----
 
----

Revision as of 15:05, August 16, 2013

When you edit multiple files, you often need to change between files. It quickly become tedious that you have to strain your fingers to Escape then go to command mode and enter one of related commands to switch to another file.

You can set up Vim in windows and gvim to switch between files with the commonly used Ctrl-Tab and Ctrl-Shift-Tab

This depends on how do you normally work.

  1. If you prefer to work with just buffers (ie., whole screen dedicated to one buffer): you can map :bn and :bp commands.
    nnoremap <C-Tab> :bn
    nnoremap <C-S-Tab> :bp
  1. If you rather use split windows all the time, you rather use CTRL-W family of commands to switch between windows.
    nnoremap <C-Tab> <C-w>w
    nnoremap <C-S-Tab> <C-w>W
  1. And if you are one of those who prefer one tab for one buffer guy, you can map :tabn and :tabp commands.
    nnoremap <C-Tab> :tabn
    nnoremap <C-S-Tab> :tabp


References


Around Wikia's network

Random Wiki