bit*_*ask 12 vim customization tabs
发布:tabnew somefile
将somefile
在当前选项卡右侧的新选项卡中打开.我可以以某种方式让Vim打开当前标签左侧的标签吗?
更新:建议的答案允许我打开一个新的选项卡,但他们打破文件名自动完成,这是一个禁忌.
要利用@romainl描述的行为而不必求助于了解当前标签页号,请使用以下命令:
command -nargs=* -bar Tabnew :execute (tabpagenr()-1).'tabnew '.<q-args>
Run Code Online (Sandbox Code Playgroud)
.注意:它完全可以保存使用0tabnew
:即使没有数字低于1的标签页,这也可以实现预期,并使新标签成为第一个标签页.
如果您确定永远不会使用此命令,++opt
或者+cmd
您可以-complete=file
在之后使用-bar
.注意:除了它的名称,它不是一个完成选项,因为它也有文件名扩展(并显示大小写中的错误-nargs=1
和以太多文件名扩展的globs).不幸的是,文档中甚至没有提到这种行为.
由于Vim的7.4.530(2014) ,可以使用负值用于[count]
在:[count]tabnew
打开的选项卡.要直接在当前选项卡的左侧打开选项卡,请使用:
:-1tabnew
Run Code Online (Sandbox Code Playgroud)
文档: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
Run Code Online (Sandbox Code Playgroud)
类似的功能也可用于:tabclose
,:tabonly
,:tabmove
,看到提交上面链接.如果这不起作用,请使用:version
检查您的Vim是否是最新的和/或用于:help tabnew
检查文档是否与此处引用的文档类似.