Vim:忽略搜索中的特殊路径
在我的 .vimrc 文件中,有两行非常有用:
set path=~/nbapp/**
set backupdir=~/nbapp/temp
第一行允许我在项目目录和子目录中进行搜索。第二行让 vim 在一个特殊的临时文件夹中创建备份文件,而不是通过添加数十个除了末尾的“~”之外名称完全相同的备份文件来打扰我。但是,由于临时文件仍然位于“nbapp”文件夹中(我想将它们保留在那里,因为它们与项目相关),这意味着当我进行搜索时它们也会被搜索,这有时会打扰我,因为我一直在查看搜索结果,但尚未发现它们实际上位于临时文件夹中。
有没有可能的方法从搜索中排除路径(即 vimgrep)?我想排除“temp”文件夹。
问候,
拉菲德
In my .vimrc file, I have two very useful lines:
set path=~/nbapp/**
set backupdir=~/nbapp/temp
The first line allows me to search in my project directory and subdirectories. The second line makes vim create backup files in a special temporary folder, rather than disturbing me by adding tens of backup files having the exact same name except for a '~' at the end. However, since the temporary files are still inside the 'nbapp' folder (and I want to keep them there because they are related to the project), it means they are also going to be searched when I make a search, which sometimes disturb me, because I keep looking at searched results, yet to discover that they are actually in the temporary folder.
Is there any possible way to exclude paths from search (i.e. vimgrep)? I want to exclude the 'temp' folder.
Regards,
Rafid
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
使用“wildignore”选项:
:set wildignore+=**/temp/**
或者如果您想更具体:
:set wildignore+=~/nbapp/temp/**
这应该排除 :find 结果中 nbapp/temp 目录中的所有文件。
Use the 'wildignore' option:
:set wildignore+=**/temp/**
or if you would like to be more specific:
:set wildignore+=~/nbapp/temp/**
This should exlude all files in the nbapp/temp directory in :find result.
我使用 grep 命令代替 vimgrep,
我会使用该设置
当我想要搜索文件但不包括标记文件和 cscope 文件时, 。
您可以修改上面的内容以不搜索任何以 ~ 结尾的文件。
我不认为你可以使用 grep 排除该文件夹(或者也许你可以,尝试 --exclude=~/nbapp/temp/* 它可能有效,我还没有测试过)。
如果这不起作用,我建议对 grepprg 使用 ack 而不是 grep。
ack 作为选项ignore-dir=name,您可以在其中显式忽略文件夹。
Instead of vimgrep I use the grep command
I use the setting
when I want to search files but excluding the tag files and cscope files.
You could modify the above to not search any files ending with a ~.
I don't think you can exclude the folder using grep (or maybe you can, try --exclude=~/nbapp/temp/* it might work I haven't tested it).
If that does not work I recomend using ack for the grepprg instead of grep.
ack as an option ignore-dir=name in which you can explicitly ignore a folder.
从
:find
和gf
中排除某些目录(例如node_modules
)你可以设置:
To exclude some dirs from
:find
andgf
(for examplenode_modules
)you can set:
例如,在 Ubuntu 中
,然后安装 http://www.vim.org/scripts/ script.php?script_id=2572
现在将下一行添加到您的 .vimrc 中
For example in Ubuntu just
then install http://www.vim.org/scripts/script.php?script_id=2572
and now add next line to your .vimrc
是删除路径条目的首选方法,因为它可以防止 vim 升级可能修改“path”的值。
is the preferred method of removing path entries, as it guards you against vim upgrades that may modify the value of 'path'.