简体   繁体   English

如何设置 Vim NERDTree 以防止显示 .git 文件夹和文件?

[英]How to set Vim NERDTree to prevent show .git folders and files?

I make visible all hidden files and folders, also, .git folders and files ( .git , .gitignore and etc.)我使所有隐藏的文件和文件夹可见,还有.git文件夹和文件( .git.gitignore等)

In a project tree when using NERDTree in Vim, I wanted to manage to show all other hidden files except .git folder and its subfolders and files.在 Vim 中使用NERDTree时,在项目树中,我想设法显示除.git文件夹及其子文件夹和文件之外的所有其他隐藏文件。

How I can do it?我该怎么做?

It worked for me.它对我有用。 Did you try the following options ?您是否尝试过以下选项?

let NERDTreeShowHidden=1

Maybe you are not at the root of your git repo and that is why you don't see any .git* files/dirs也许您不在 git 存储库的根目录下,这就是为什么您看不到任何.git* files/dirs

在 NerdTree 窗口中按 Shift+I

Actually, the question post wants to show all hidden files and folders but ignore some files or folders like .git folder.实际上,问题帖子想要显示所有隐藏的文件和文件夹,但忽略一些文件或文件夹,如.git文件夹。 for this setting:对于此设置:

  1. We should show all hidden files and folders by default, so open the .vimrc file and at the end of file insert the following command:我们应该默认显示所有隐藏的文件和文件夹,所以打开.vimrc文件并在文件末尾插入以下命令:
let NERDTreeShowHidden=1
  1. We should ignore some files or folders like other IDEs, so open the .vimrc file again and the end of file insert the following command too:我们应该像其他 IDE 一样忽略一些文件或文件夹,因此再次打开.vimrc文件并在文件末尾插入以下命令:
let NERDTreeIgnore=['\.git$']

Hint : recently I migrated from VSCode and WebStorm to Vim so on the second step I ignore some other files and folders, I mean:提示:最近我从VSCodeWebStorm迁移到Vim所以在第二步我忽略了其他一些文件和文件夹,我的意思是:

let NERDTreeIgnore=['\.git$', '\.idea$', '\.vscode$', '\.history$']

只需将以下内容添加到您的.vimrc文件中:

let NERDTreeIgnore=[".git"]

Try using this尝试使用这个

let g:NERDTreeIgnore = ['\.git$']

Note that it must start with " \\ " and end with "$".请注意,它必须以“\\”开头并以“$”结尾。 This works for Windows, Linux and MacOs这适用于 Windows、Linux 和 MacOs

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM