Is there a vim command to relocate a tab?

前端 未结 7 1614
南笙
南笙 2021-01-29 18:16

How can I change the position / order of my current tab in Vim? For example, if I want to reposition my current tab to be the first tab?

7条回答
  •  心在旅途
    2021-01-29 19:14

    Here's my macro, using relative arguments from @maybeshewill's answer:

    " Shortcuts to move between tabs with Ctrl+Shift+Left/Right
    function TabLeft()
       if tabpagenr() == 1
          execute "tabm"
       else
          execute "tabm -1"
       endif
    endfunction
    
    function TabRight()
       if tabpagenr() == tabpagenr('$')
          execute "tabm" 0
       else
          execute "tabm +1"
       endif
    endfunction
    
    map  :execute TabRight()
    map  :execute TabLeft()
    

    It handles the wrapping case.

提交回复
热议问题