How to set Vim NERDTree to prevent show .git folders and files?
Asked Answered
T

6

13

I make visible all hidden files and folders, also, .git folders and files (.git, .gitignore and etc.)

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.

How I can do it?

Torment answered 3/2, 2014 at 18:11 Comment(3)
Did you try 'I' in NERDTree window?Agglutinate
thanks - I just found solution - in my .vimrc I had ignored .git files on nerdtree with let NERDTreeIgnore=["\.git"].quick tip - I found that you can toggle hidden files in nerd tree with shift+iTorment
Dear @carousel, I leave an upvote for your great question, it is very useful to migrate from modern IDEs to Vim. also I make a large edit on your question and additionally add a complete answer for future users.Mariellemariellen
S
17

Press Shift+I when in the NerdTree window

Sweaty answered 10/12, 2015 at 22:10 Comment(0)
G
13

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

Galilee answered 3/2, 2014 at 22:28 Comment(0)
M
9

Actually, the question post wants to show all hidden files and folders but ignore some files or folders like .git folder. 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:
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:
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:

let NERDTreeIgnore=['\.git$', '\.idea$', '\.vscode$', '\.history$']
Mariellemariellen answered 12/3, 2020 at 13:34 Comment(0)
B
2

Just add the following to your .vimrc file:

let NERDTreeIgnore=[".git"]
Bethannbethanne answered 9/9, 2020 at 18:9 Comment(0)
A
0

Try using this

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

Note that it must start with " \ " and end with "$". This works for Windows, Linux and MacOs

Abohm answered 21/8, 2021 at 0:57 Comment(0)
P
0

If you want to do it in lua config files: (for nvim users)

filters = {
   dotfiles = false,
   custom = {"^\\.git"},
},
Phial answered 30/7, 2023 at 5:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.