発行は、現在のタブの右側に新しいタブで:tabnew somefile
開きます。Vim で現在のタブの左側にあるタブを開くことはできますか?somefile
更新:提案された回答により、新しいタブを左に開くことができますが、ファイル名の自動補完が壊れてしまいます。
発行は、現在のタブの右側に新しいタブで:tabnew somefile
開きます。Vim で現在のタブの左側にあるタブを開くことはできますか?somefile
更新:提案された回答により、新しいタブを左に開くことができますが、ファイル名の自動補完が壊れてしまいます。
Vim 7.4.530 (2014)以降、 [count]
inに負の値を使用:[count]tabnew
してタブを開くことができます。現在のタブのすぐ左にあるタブを開くには、次を使用します。
:-1tabnew
ドキュメント: https://vimhelp.appspot.com/tabpage.txt.html#:tabnew
:[count]tabe[dit] :tabe :tabedit :tabnew
:[count]tabnew
Open a new tab page with an empty window, after the current
tab page. If [count] is given the new tab page appears after
the tab page [count] otherwise the new tab page will appear
after the current one.
:tabnew " opens tabpage after the current one
:.tabnew " as above
:+tabnew " opens tabpage after the next tab page
" note: it is one further than :tabnew
:-tabnew " opens tabpage before the current one
:0tabnew " opens tabpage before the first one
:$tabnew " opens tabpage after the last one
:tabclose
、:tabonly
、にも同様の機能があります:tabmove
。上記のリンクのコミットを参照してください。これが機能しない場合は、 を使用:version
して Vim が最新:help tabnew
かどうかを確認するか、ドキュメントがここで引用されているものと同じかどうかを確認してください。
現在のタブページ番号を知らなくても @romainl で説明されている動作を利用するには、次のコマンドを使用します。
command -nargs=* -bar Tabnew :execute (tabpagenr()-1).'tabnew '.<q-args>
. 注:使用するのに完全に保存されます0tabnew
:これは意図したとおりに機能し、1未満の番号を持つタブページがなくても、新しいタブを最初のタブにします.
このコマンドを絶対に使用しないことが確実な場合、++opt
またはの直後に+cmd
使用できます。注: その名前に加えて、ファイル名の展開も行うため、補完オプションではありません(また、ファイル名が多すぎる場合にエラーが表示され、展開されたグロブが表示されます)。残念ながら、この動作はドキュメントにも記載されていません。-complete=file
-bar
-nargs=1
を使用できます[count]
。タブ #4 にいると仮定すると:3tabnew
、現在のタブの左側に新しいタブが作成されます。
ただし、タブは常に現在のタブまたはタブ # の右側に作成されることに注意してください[count]
。事実上、「タブ #3の後:3tabnew
に新しいタブを作成する」ことを意味します。
You can write your own command to do this
:command -nargs=1 TabnewBefore exec "tabnew <args>" | exec "tabmove -1"
Then to use it
:TabnewBefore somefile
If you want it to be the default 'tabnew' bahaviour you can do
:ca tabne TabnewBefore
Now if you type tabne
and press space on the command line it does what you want, if you want the original behaviour type the full command tabnew
You can put these definitions into your .vimrc file for future use