How do I reorder tab pages in Vim without specifying an absolute position?
Answer
:tabmove +1
Explanation
:tabmove normally takes an absolute position (:tabmove 0 moves the tab to the far left), but it also accepts relative offsets using + and -. This makes it trivial to nudge the current tab left or right without having to count its index — just use :tabmove +1 or :tabmove -1 to shift it one position.
How it works
:tabmove +Nmoves the current tab N positions to the right:tabmove -Nmoves the current tab N positions to the left:tabmove 0moves the tab to the first (leftmost) position (absolute):tabmove $moves the tab to the last (rightmost) position (absolute)- With no argument,
:tabmovemoves the tab to the last position (same as$)
Example
You have four tabs open and the active tab is in position 2 (0-indexed):
[A] [B] [*C*] [D]
Running :tabmove +1 shifts tab C one position to the right:
[A] [B] [D] [*C*]
Running :tabmove -2 shifts it two positions left:
[*C*] [A] [B] [D]
Tips
- Map
:tabmove -1and:tabmove +1to convenient keys for quick reordering (e.g.<leader>[and<leader>]) - Relative moves are safer than absolute when you have many tabs and don't remember exact positions
- Works in combination with
:tabdoand other tab commands