FANDOM


(Fix links using VimTipNr where target has been merged)
(Remove html character entities)
Line 14: Line 14:
 
Add the following lines to your vimrc:
 
Add the following lines to your vimrc:
 
<pre>
 
<pre>
map &lt;C-t&gt; :tabnew&lt;CR&gt;
+
map <C-t> :tabnew<CR>
map &lt;C-left&gt; :tabp&lt;CR&gt;
+
map <C-left> :tabp<CR>
map&lt;C-right&gt; :tabn&lt;CR&gt;
+
map<C-right> :tabn<CR>
 
</pre>
 
</pre>
   
Line 41: Line 41:
 
<pre>
 
<pre>
 
" Tab mappings
 
" Tab mappings
map &lt;S-Up&gt; :tabclose&lt;CR&gt;
+
map &lt;S-Up> :tabclose<CR>
map &lt;S-Down&gt; :tabnew&lt;CR&gt;
+
map &lt;S-Down> :tabnew<CR>
map &lt;S-Left&gt; gT
+
map &lt;S-Left> gT
map &lt;S-Right&gt; gt
+
map &lt;S-Right> gt
map &lt;S-PageUp&gt; :tabfirst&lt;CR&gt;
+
map &lt;S-PageUp> :tabfirst<CR>
map &lt;S-PageDown&gt; :tablast&lt;CR&gt;
+
map &lt;S-PageDown> :tablast<CR>
 
</pre>
 
</pre>
   
Line 52: Line 52:
   
 
----
 
----
I prefer <tt>gt</tt> and <tt>gT</tt>. In any case &lt;C-PgUp&gt; and &lt;C-PgDn&gt; are the defaults for the same operations.
+
I prefer <tt>gt</tt> and <tt>gT</tt>. In any case <C-PgUp> and <C-PgDn> are the defaults for the same operations.
   
Just opening a new tab is kind of useless. I find <tt>:tabe &lt;filename&gt;</tt> more useful.
+
Just opening a new tab is kind of useless. I find <tt>:tabe <filename></tt> more useful.
   
 
----
 
----
Line 60: Line 60:
   
 
----
 
----
If you are working with tags or cscope, &lt;Ctrl-T&gt; is for popping the stack.
+
If you are working with tags or cscope, <Ctrl-T> is for popping the stack.
   
 
----
 
----
Line 68: Line 68:
 
</pre>
 
</pre>
   
Alternative way to move current window to a new tab is: &lt;Ctrl-w&gt; T (capital).
+
Alternative way to move current window to a new tab is: <Ctrl-w> T (capital).
   
 
----
 
----

Revision as of 00:16, September 30, 2008

Tip 1347 Printable Monobook Previous Next

created September 29, 2006 · complexity basic · author mchenryk · version 7.0


Add the following lines to your vimrc:

map <C-t> :tabnew<CR>
map <C-left> :tabp<CR>
map<C-right> :tabn<CR>

Then in gvim you have the following commands:

  • Ctrl-t – open a new tab
  • Ctrl-left arrow – move one tab to the left
  • Ctrl-right arrow – move one tab to the right

Comments

 TO DO 

  • Fix tip so it explains basics of tab navigation.
  • No point having a tip change the default keybindings for :tabn and :tabp. Explain the defaults.
  • Merge in any useful comments from below.
  • Perhaps rename to "Using tab pages" (a simpler title that attempts to avoid confusion with the tab key).

Does not work in [ax]term.


Or you could use gt and gT without having to move your hands across the keyboard. Also, gt can take the tab number to jump directly to a tab.


I use Vim in Windows, so remapping C-Left isn't great for me. These are the mappings I use:

" Tab mappings
map <S-Up> :tabclose<CR>
map <S-Down> :tabnew<CR>
map <S-Left> gT
map <S-Right> gt
map <S-PageUp> :tabfirst<CR>
map <S-PageDown> :tablast<CR>

I used down for a new tab because I'm used to that from Opera's mouse gestures.


I prefer gt and gT. In any case <C-PgUp> and <C-PgDn> are the defaults for the same operations.

Just opening a new tab is kind of useless. I find :tabe <filename> more useful.


Instead of :tabe filename, I like :tabf filename, because it walks the path to find the name, instead of relying on an required explicit path/filename.


If you are working with tags or cscope, <Ctrl-T> is for popping the stack.


I think this can be condensed to:

:tab sp<CR>

Alternative way to move current window to a new tab is: <Ctrl-w> T (capital).


When you use :tab ball - it makes out of all buffers a tab.


Community content is available under CC-BY-SA unless otherwise noted.