Nerdtree: Indentation spaces

Created on 24 Sep 2020  路  2Comments  路  Source: preservim/nerdtree

Hello, thanks for maintaining a plugin I use every day.

Would you consider adding a configuration variable like NERDTreeIndentSpaces=1 ?

Sometimes I work on deeply nested projects and it would mean I could keep NERDTree a bit smaller (so my buffers can be bigger), while still seeing all the relevant information.

I appreciate this is a bit of a petty request. I had a quick go at adding this myself but when I changed the code that renders the menu, I could no longer open menu items and I couldn't figure out why.

Thanks

feature request

Most helpful comment

@tuzz , as you discovered, changing NERDTree code is an adventure. I have looked at this very thing myself, and decided at the time to abandon any further changes. Instead I wrote a syntax file to accomplish the same thing. Here it is. Make sure you save it to the right location: ~/.vim/after/syntax/nerdtree.vim.

" This file adds some customization to the syntax highlighting in NERDTree.
" Requirements:
"  * Vim must be compiled with the +conceal feature turned on.
"  * The file must be saved here: ~/.vim/after/syntax/nerdtree.vim

if !has("conceal")
    finish
endif

let s:dirArrows = escape(g:NERDTreeDirArrowCollapsible, '~]\-').escape(g:NERDTreeDirArrowExpandable, '~]\-')

syntax clear NERDTreeOpenable
syntax clear NERDTreeClosable

" ----------------------------------------------------------------------------
" This statement changes the indentation of NERDTree to appear as 1 space per
" level instead of the normal 2 spaces.
exec 'syntax match CompressSpaces #['.s:dirArrows.' ]\zs \ze.*' . g:NERDTreeNodeDelimiter . '# containedin=ALL conceal'

All 2 comments

@tuzz , as you discovered, changing NERDTree code is an adventure. I have looked at this very thing myself, and decided at the time to abandon any further changes. Instead I wrote a syntax file to accomplish the same thing. Here it is. Make sure you save it to the right location: ~/.vim/after/syntax/nerdtree.vim.

" This file adds some customization to the syntax highlighting in NERDTree.
" Requirements:
"  * Vim must be compiled with the +conceal feature turned on.
"  * The file must be saved here: ~/.vim/after/syntax/nerdtree.vim

if !has("conceal")
    finish
endif

let s:dirArrows = escape(g:NERDTreeDirArrowCollapsible, '~]\-').escape(g:NERDTreeDirArrowExpandable, '~]\-')

syntax clear NERDTreeOpenable
syntax clear NERDTreeClosable

" ----------------------------------------------------------------------------
" This statement changes the indentation of NERDTree to appear as 1 space per
" level instead of the normal 2 spaces.
exec 'syntax match CompressSpaces #['.s:dirArrows.' ]\zs \ze.*' . g:NERDTreeNodeDelimiter . '# containedin=ALL conceal'

Thanks @PhilRunninger, that's working perfectly!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nicknick63 picture nicknick63  路  6Comments

Coleej picture Coleej  路  3Comments

nicknisi picture nicknisi  路  5Comments

yuanjianpeng picture yuanjianpeng  路  5Comments

kevinSuttle picture kevinSuttle  路  4Comments