[英]In Vim tab-completion of file names doesn't work
When I try to open a file in Vim (Linux) for editing, when I press TAB, Vim autocompletes filename only with filenames from the current directory.当我尝试在 Vim (Linux) 中打开文件进行编辑时,当我按 TAB 时,Vim 仅使用当前目录中的文件名自动完成文件名。 However, having searched on the Web, I suppose that from version 7 Vim should support bash-like filename autocompletion using filenames from all the directories in the search path.
但是,在网上搜索后,我想从版本 7 开始,Vim 应该支持使用搜索路径中所有目录中的文件名的类似 bash 的文件名自动完成。
Say, there is a file file1
in a directory dir1
(which directory is also in the environment variable PATH).比如说,目录
dir1
中有一个文件file1
(该目录也在环境变量 PATH 中)。
I type the following commands in Vim:我在 Vim 中输入以下命令:
set path=/dir1
set wildmode=list:longest
And then, when I type:然后,当我输入:
:e fil<TAB>
The filename is not autocompleted.文件名不会自动完成。 How to enable this feature in Vim?
如何在 Vim 中启用此功能?
Tab-completion works.制表符完成工作。 You just expect it to do something it is not actually supposed to do.
你只是期望它做一些它实际上不应该做的事情。
:e[dit]
and its siblings ( :sp[lit]
, :vs[plit]
, :tabe[dit]
) don't use the path
option at all, no matter what version of Vim you have. :e[dit]
和它的兄弟姐妹( :sp[lit]
, :vs[plit]
, :tabe[dit]
)根本不使用path
选项,不管你有什么版本的 Vim。
Use :fin[d] fil<Tab>
instead (and :sf[ind]
, :vert sf[ind]
, :tabf[ind]
).使用
:fin[d] fil<Tab>
代替(和:sf[ind]
, :vert sf[ind]
, :tabf[ind]
)。
Use set path=/dir1/**
to make :find
recursive.使用
set path=/dir1/**
使:find
递归。
See :help 'path'
and :help :find
.请参阅
:help 'path'
和:help :find
。
edit编辑
It is generally considered "good practice" to start Vim from the root of your project:从项目的根目录启动 Vim 通常被认为是“好习惯”:
$ cd /path/to/project
$ vim somefile
The main advantage being that it sets Vim's "current directory" to a usable value that allows you to browse your project relatively easily or use external programs on your project in a clean and intuitive way.主要优点是它将 Vim 的“当前目录”设置为可用值,使您可以相对轻松地浏览项目或以干净直观的方式在项目中使用外部程序。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.