Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

vim

nerdtree

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?

like image 843
Miroslav Trninic Avatar asked Feb 03 '14 18:02

Miroslav Trninic


4 Answers

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$']
like image 140
AmerllicA Avatar answered Nov 13 '22 18:11

AmerllicA


Press Shift+I when in the NerdTree window

like image 43
Petur Subev Avatar answered Nov 13 '22 17:11

Petur Subev


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

like image 13
Nakul Avatar answered Nov 13 '22 17:11

Nakul


Just add the following to your .vimrc file:

let NERDTreeIgnore=[".git"]
like image 2
Mahdi Naderian Avatar answered Nov 13 '22 18:11

Mahdi Naderian