Vim Tips Wiki
Register
(Move categories to tip template)
(Remove html character entities)
Line 15: Line 15:
   
 
<pre>
 
<pre>
noremap &lt;silent&gt;&lt;C-S-w&gt; :if tabpagenr() != tabpagenr('$')&lt;cr&gt;:tabclose&lt;cr&gt;:if tabpagenr() &gt; 1&lt;cr&gt;:tabprev&lt;cr&gt;:endif&lt;cr&gt;:else&lt;cr&gt;:tabclose&lt;cr&gt;:endif&lt;cr&gt;
+
noremap <silent><C-S-w> :if tabpagenr() != tabpagenr('$')<CR>:tabclose<CR>:if tabpagenr() > 1<CR>:tabprev<CR>:endif<CR>:else<CR>:tabclose<CR>:endif<CR>
 
</pre>
 
</pre>
   
 
==Comments==
 
==Comments==
 
----
 

Revision as of 00:15, 30 September 2008

Tip 1333 Printable Monobook Previous Next

created September 19, 2006 · complexity basic · author mz · version n/a


The default is that when you close a tab, the tab to the right of the tab you just closed becomes the current tab. This mapping closes the current tab and makes the tab to the left of the tab you just closed the current tab. I like this to provide symmetry with tabopen (new tabs go to the right of the tab you were just on). This way, if I'm editing a file, and do something quickly in a new tab, then close that tab, I get back to my original tab. Obviously the keys for the mapping can be changed to whatever you want.

noremap <silent><C-S-w> :if tabpagenr() != tabpagenr('$')<CR>:tabclose<CR>:if tabpagenr() > 1<CR>:tabprev<CR>:endif<CR>:else<CR>:tabclose<CR>:endif<CR>

Comments