Vim:打开新的资源管理器选项卡,其中包含您当前所在文件的目录
我想打开一个新选项卡,将文件资源管理器设置为我打开的文件的目录,而不是我打开 vim 的目录。例如,
如果我这样做:
~: cd ~/dir1
~/dir1: vim dir2/dir3/dir4/file1
那么从该窗口内部打开一个新选项卡,其中文件资源管理器当前显示 ~/dir1/dir2/dir3/dir4/ 的内容(目录当前活动选项卡中的文件)。
我设置了以下映射:
nnoremap <leader>t :tabnew<CR>:Ex . <CR>
但这只是打开 ~/dir1
处的文件资源管理器。如何编辑此键映射以将当前打开的文件的目录传递给 :Ex
?
I'd like to open a new tab with the file explorer set to the directory of the file I have open, instead of the directory I opened vim from. For example,
If I do:
~: cd ~/dir1
~/dir1: vim dir2/dir3/dir4/file1
Then from inside that window I would like to open a new tab with a file explorer currently showing the contents of ~/dir1/dir2/dir3/dir4/
(the directory of the file in the currently active tab).
I have the following mapping set up:
nnoremap <leader>t :tabnew<CR>:Ex . <CR>
But that just opens the file explorer at ~/dir1
. How can I edit this key-mapping to pass to :Ex
the directory of the file that is currently open?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
除了 François 的答案之外,您还可以打开新的拆分窗口,以防您想分别使用
:Hexplore
或:Vexplore
进行水平或垂直并排比较。Alternatively to François 's answer, you can also open new split window, in case you want to do comparison side by side horizontally or vertically by using
:Hexplore
or:Vexplore
respectively.除了
:tabe %:h
之外,还有:Texplore
或简单的
:Te
Alternatively to
:tabe %:h
, there is also:Texplore
or simply
:Te
打开一个选项卡,编辑“当前文件名的头”(
%
是当前文件的名称,:
添加修饰符,h
> 是基本名称/头修饰符),即目录。Opens a tab, editing the 'head of current file-name' (
%
is the name of the current file,:
adds modifiers, andh
is the basename/head modifier), that is the directory.