Nerdtree: Option to change the default indent size

Created on 4 Jun 2018  路  11Comments  路  Source: preservim/nerdtree

Hi,

I would like to know if there's an option to change (and especially reduce) the size of indent in the tree ? If that's not possible currently, then let's call this a feature request. What I mean by the size of indent is the red thing in this screenshot:

new document

Thanks.

Most helpful comment

I don't see that as an issue. It's standard practice to put all siblings (files and directories) at the same indentation level. The triangle should not be considered part of the directory name.

I'm not saying it's an issue. Only that I'd prefer it like this but I understand it's probably not the case for most users.

One thing that could be done would be to add an option consider triangle as part of the directory name, set it to false as default. If it's set to yes, you just have to remove an indent level for files.

I would also completely understand that you don't want to add this as an option. In this case, could you possibly point me to the part of the code that computes the number of indent for files ? I'll just add a local patch to get the behavior I want. :)

The only reason your filenames are pushed to the right is, as you discovered, the tags being introduced by ryanoasis/vim-devicons and Xuyuanp/nerdtree-git-plugin.

It's only because of nerdtree-git-plugin (I opened an issue there), vim-devicons is fine.

All 11 comments

There is no such setting in NERDTree. It uses 2 spaces per level, with the root being level 1. The files shown in your screenshot, then should be in column 3.

image

I suspect the extra spaces are being put in by whatever plugin is supplying the lambda character to NERDTree. Take a look at its options, and let us know what you find.

OK, so actually, I think there's two things.

  1. It's not from the plugin supplying the lambda character, which is ryanoasis/devicons, but from this one: Xuyuand/nerdtree-git-plugin. The thing is that, there's extra indent when there's no icon, with one icon as an example it makes more sense, see this screenshot:

capture du 2018-06-06 23-20-22

  1. There's still a thing with nerdtree, which is that, folders and files in the same level are not indented the same way because of the arrow icon. On your screenshot, > syntax and CHANGELOG does not start at the same level (if you consider that the arrow is part of the thing). This is what I'd like to change. It can be fixed by removing one level of indentation on each file line.

I don't see that as an issue. It's standard practice to put all siblings (files and directories) at the same indentation level. The triangle should not be considered part of the directory name. In my screenshot, since syntax/ and CHANGELOG are siblings, they should be at the same indentation, based on the text of their actual names, and in fact, they are. In yours, src/ and _oasis are siblings and they both start in column 3. The only reason your filenames are pushed to the right is, as you discovered, the tags being introduced by ryanoasis/vim-devicons and Xuyuanp/nerdtree-git-plugin.

This is not a bug, nor something we will be changing, so I'm going to close this issue.

I don't see that as an issue. It's standard practice to put all siblings (files and directories) at the same indentation level. The triangle should not be considered part of the directory name.

I'm not saying it's an issue. Only that I'd prefer it like this but I understand it's probably not the case for most users.

One thing that could be done would be to add an option consider triangle as part of the directory name, set it to false as default. If it's set to yes, you just have to remove an indent level for files.

I would also completely understand that you don't want to add this as an option. In this case, could you possibly point me to the part of the code that computes the number of indent for files ? I'll just add a local patch to get the behavior I want. :)

The only reason your filenames are pushed to the right is, as you discovered, the tags being introduced by ryanoasis/vim-devicons and Xuyuanp/nerdtree-git-plugin.

It's only because of nerdtree-git-plugin (I opened an issue there), vim-devicons is fine.

Removing this block of code will do what you are requesting: https://github.com/scrooloose/nerdtree/blob/master/lib/nerdtree/tree_file_node.vim#L347-L349. Be aware that your nerdtree will be out of date with the official version.

Thanks, it works as I wanted. :)

(I just forked the repo, added a commit and I have some script to pull from upstream automatically, should be fine.)

I like the solution of zapashcanon, why wasn't it merged with this project?

Because the current behavior is the expected one. One thing that could be done is to add an option that the user has to set and rewrite the code pointed out by @PhilRunninger so it checks for it.

wait it works with the indentation but doesn't open the files, when I am pressing enter () or "o" doesn't work.. I tried a global variable g:Indentantion = '' and
let treeParts = treeParts . g:Indentantion
and it's the same.

There are several places in the code that are coupled, and changing one without changing the others is problematic. I'm working on some changes to address a bunch of other issues, and indentation is becoming something I have to deal with. Let's see where that goes before tackling this any further.

It uses 2 spaces per level, with the root being level 1.

Can this be configurable? Having only a single space in root gets Vim DevIcons unaligned only for root files:
image

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nicknick63 picture nicknick63  路  6Comments

PinheiroCosta picture PinheiroCosta  路  4Comments

sunnyguan picture sunnyguan  路  4Comments

yuanjianpeng picture yuanjianpeng  路  5Comments

trygvis picture trygvis  路  6Comments