Nerdtree: changing the info displayed in the tree

55 views Asked by At

This may be an odd question, but I want to use vim for journaling/personal log. My notes are going to be in a folder named "2024" with each month as a separate txt file.

In each monthly .txt file, I'll get my entries with a format like this, using * and ** for hierarchical order:

* SUNDAY 28 --> the date of each daily entry

** Did thing A --> a short description of something interesting

** Did thing B --> a short description of something interesting

Thing A happened. A long and detailed description of thing A.

Thing B happened. A long and detailed description of the thing B.

* MONDAY 29 ... another entry with the same format.

The idea is to see ON THE TREE the date and the headers with the short description of the most important things (thing A and thing B) that happened that day under the date so I can have a quick summary of what happened, and if I want, go to that subject. If I hit ENTER on any of the date or the short description, it shows the full entry for that thing on the right window.

Can something like this be done? Please don't make me go to Emacs.

Thanks!

1

There are 1 answers

3
Friedrich On

NERDTree has a whole different purpose as was established in the comments. What you ask for will not be possible using NERDTree.

However, Vim's folding feature (documented in :help fold.txt) can be used to organize hierarchical data and hide (fold) some items.

A very simple example could look like this:

* SUNDAY 28 {{{1
** Did thing A {{{
    I spent the whole day doing thing A. You know how much fun thing A can be.
    Really, time flew by as I was thinking of nothing but thing A.
** Did thing B {{{2
    Doing thing B was also great!
}}}1
* MONDAY 29 {{{1
}}}1

vim: set fen fdm=marker:

Note the modeline which is used to :set foldenable and :set foldmethod=marker. The {{{ and }}} are fold markers with an optional number to give the nesting level. You can match opening and closing markers, postfix them with a number or use both methods interchangeably. Note that I did just that to illustrate the point. In a real file, I'd stick with one method to avoid confusion.

There are other methods to fold and they are documented. For the purpose of a little diary, I think markers may be a good choice.

When you open this file in Vim, it should look somewhat like this:

+--  9 lines: * SUNDAY 28 ----------------------------------------------
+--  2 lines: * MONDAY 29 ----------------------------------------------

vim: set fen fdm=marker:

You can go on either day and open a fold for Sunday using zo which will unfold the file to

* SUNDAY 28 {{{1
+---  3 lines: ** Did thing A ------------------------------------------
+---  4 lines: ** Did thing B ------------------------------------------
}}}1
+--  2 lines: * MONDAY 29 ----------------------------------------------

vim: set fen fdm=marker:

You can also set a global level using :set foldlevel=1 to unfold all level 1 folds.

Entering insert mode will open the respective fold so you will always see what you're writing.