How to change tabs order in VIM?
Is there a way to change tabs order in Vim
(i.e. change the position of the tabs in the tab bar)? For example, let's say my current tabs are in this order:
A | B | C | D
But I would like to switch the position of the tabs to something like:
A | C | B | D
How can I do that?
Solution 1:
You can use :tabmove
followed by the tab number to move past. For example, :tabmove 3
will make the current tab move past the 3rd. :tabmove 0
moves to the beginning and :tabmove
(without a number) moves to the end.
Another way - though not orthodox - is to enable mouse via :set mouse=a
and drag-and-drop tabs around. It might look simpler for a start.
Solution 2:
Move Tabs to the Left / Right
To me it makes much more sense to move the tabs to the left or right of their current position instead of first figuring out the exact numerical position I want them at. These simple keymaps do exactly that:
noremap <A-Left> :-tabmove<cr>
noremap <A-Right> :+tabmove<cr>
Now you'll be able to move the current tab:
- To the left using: Alt + Left
- To the right using: Alt + Right
For MacVim, try using M
instead of A
(i.e. <M-Left>
)
Solution 3:
For me -tabmove is not working.
I'm using below command: Ctrl+Shift+PageUp|PageDown.
nmap <C-S-PageUp> :tabmove -1<cr>
nmap <C-S-PageDown> :tabmove +1<cr>