使用命令-T 搜索

发布于 2024-12-12 06:52:14 字数 316 浏览 0 评论 0原文

当我使用命令-T 搜索某个文件时,经常找不到它,因为我不在正确的目录中,所以我必须更改目录。

是否可以设置 command-T 首先在 Nerdtree 或其他地方添加书签的目录中进行搜索?

我可以将目录更改为 / 但此搜索的文件范围非常大。当我将目录更改为我的主目录并且正在寻找诸如 .bashrc 之类的普通文件时,我会发现相当多的文件位于 .wine 目录下。

在 99% 的时间里,我需要在我经常使用的项目目录中搜索文件。我可以在某些首选项中设置这些目录吗?

When I search some file with command-T it often failes to find it because I'm not in the right directory, so I have to change the directory.

Is it possible to set that command-T will search first in the directories that are bookmarked in Nerdtree or somewhere else?

I could change the directory to / but this search very large scope of files. When I change the dir to my home directory and I'm looking for something ordinary like .bashrc I will find rather many files that are located under .wine directory.

In 99 % of time I need to search files in project directories that I actively work with. Can I set these directories in some preferences?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦太阳 2024-12-19 06:52:14

根据文档,您可以从搜索中排除目录:

<前><代码> *命令-t-wildignore*
|'狂野'|字符串(默认值:'')

Vim 的 |'wildignore'|设置用于确定哪些文件应该
从列表中排除。这是一个以逗号分隔的全局模式列表。
默认为空字符串,但常见设置包括“*.o,*.obj”
(排除目标文件)或“.git,.svn”(排除 SCM 元数据)
目录)。例如:

:set wildignore+=*.o,*.obj,.git

诸如“vendor/rails/**”之类的模式将排除所有文件,并且
“vendor/rails”目录中的子目录(相对于
Command-T 开始的目录)。

因此,如果您想排除备份目录,您可以

set wildignore+=project/backup

在 .vimrc 中

编写:另外,要忽略 dotfiles/dotdirs,您可以查看这些选项:

g:CommandTNeverShowDotFiles
g:CommandTScanDotDirectories
g:CommandTMaxDepth

这些选项允许您:
- 完全忽略点文件;
- 停止在 dotdirs 中递归搜索;
- 指定 Command-T 应在什么深度停止扫描。

我在 作者的 git,但您可能可以通过在 vim 中发出以下命令来查看此文档:(

:help Command-T

或类似的名称)

我没有在插件中看到任何对首选项或书签的引用。
但是,如果您通过打开所述项目目录中的文件来启动 vim,您可能需要将此行添加到 .vimrc 中:

    set autochdir

此选项将在启动时将您的目录设置为当前文件的目录。

According to the documentation you can exclude directories from your search:

                                            *command-t-wildignore*
  |'wildignore'|                                 string (default: '')

   Vim's |'wildignore'| setting is used to determine which files should be
  excluded from listings. This is a comma-separated list of glob patterns.
  It defaults to the empty string, but common settings include "*.o,*.obj"
  (to exclude object files) or ".git,.svn" (to exclude SCM metadata
  directories). For example:

     :set wildignore+=*.o,*.obj,.git

   A pattern such as "vendor/rails/**" would exclude all files and
  subdirectories inside the "vendor/rails" directory (relative to
  directory Command-T starts in).    

So if you wanted to exclude a backup dir, you would write:

set wildignore+=project/backup

in your .vimrc

In addition, to ignore dotfiles/dotdirs you can look into these options:

g:CommandTNeverShowDotFiles
g:CommandTScanDotDirectories
g:CommandTMaxDepth

These allow you to:
- ignore dotfiles completely;
- stop searching recursively in dotdirs;
- specify at what depth should Command-T stop scanning.

I found this information in the author's git, but you can probably see this document by issuing in vim:

:help Command-T

(or a similar name)

I did not see any reference to preferences or bookmarks in the plugin.
However if you start vim by opening a file in said project directory you might want to add this line to your .vimrc:

    set autochdir

This option will set on startup your directory to the current file's directory.

忆伤 2024-12-19 06:52:14

您可以尝试 Ctrl-P。我遇到了和你一样的问题,并且做出改变解决了这些问题。

我还忽略了一些文件夹(在 .vimrc 中):

let g:ctrlp_custom_ignore = {
\ 'dir':  '\.git$\|\.hg$\|\.svn
,
\ 'file': '\.exe$\|\.so$\|\.dll
 }

You could try Ctrl-P. I had the same problems as you do and making the change solved them.

I also ignore some folders (in .vimrc):

let g:ctrlp_custom_ignore = {
\ 'dir':  '\.git$\|\.hg$\|\.svn
,
\ 'file': '\.exe$\|\.so$\|\.dll
 }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文