Ideas for my note-taking workflow

@workflow @idea

Increasingly based on ZettelkastenThe Zettelkasten method was developed by sociologist Niklas Luhmann, who used it to write over 70 books and 400 articles..

TODOs are spread all over the fileThis is a meta-note about organizing notes — naturally it has its own organizational challenges.

TODO have a tag list but also show per tag how many files. Upon selecting a tag, open a file showing all files for that tag.

TODO notational-fzf: search for a Zettel and create it when it does not already exist.

References

In my own Zettelkasten:

Vim + Zettelkasten

  • Came across this interview on How to Make Yourself into a Learning Machine .
  • Vimrc that has a Zettelkasten setup (copied verbatim below, as backup)
  • Awesome Vim Zettelkasten demo
  • Zettelkasten + Vim + plain text in Haskell

  • [ ] Timestamp all posts to provide them with a unique identifier.

    • If I want to rely heavily on links between files, I need a method for not breaking links when filenames change.
    • Is there a method for linking with identifiers without needing the timestamp to be in the filename?
    • Alternatively, I would need to write a program that scans the whole archive for the old filename, to update the links
  • [ ] Add a 'last modified' remark that updates on writing
    • In principle, I could outsource this to something like git blame
  • [ ] How to search on multiple custom defined tags at once?
    • Can you do this already with the existing TagSearch function, by passing a pattern?
    • If yes, might be still a good idea to create a wrapper function that takes multiple tags and calls TagSearch with the correct arguments.
  • [ ] Write a script that writes all tags to a 'ctags' format. Normally in code you only define a definition once and then have various locations where you use it. But you should be able to find all different locations. I think you by default do -] to jump to the last tag. But if you run g-] you should find all locations corresponding to the tag. What you essentially do is create ambiguous tags.
    • See https://www.youtube.com/watch?v=XA2WjJbmmoM 21 mark.
    • Search tags with ts[elect] (refers to last tag if no match)
    • -] tag under cursor (also usable with helptags)
    • -g] ambiguous tags (actually, g] immediately opens a list)
    • -t jump back up the tag stack. (This is nice for going down the rabbithole and having any chance of coming back out again)
    • I think you can run ctags with a regex? This would already solve the problem.
    • Suggested answer: https://vi.stackexchange.com/questions/268/creating-tags-between-markdown-files-similar-to-h
    • Extending ctags: file:///C:/Program%20Files%20(x86)/ctags58/EXTENDING.html

Ctags

Right now I have in my .ctags file:

--langdef=markdown
--langmap=markdown:.md
--regex-markdown=/@(\w+)/\1/t,tag,tags/
--regex-markdown=/[^!]\[.*\]\([\s\.]*[\\\/]?(.*?)\s?:?\s?\d*\)/\1/l,link,links/ 

Change:

--regex-markdown=/@(\w.*)\s/\1/t,tag,tags/

This one also matches post-phenomenology as a whole. I tried to make a lazy version but that didn't seem to work somehow. Now the whole sentence is matched.

--regex-markdown=/@(\w.*?)\s/\1/t,tag,tags/

Clear limitation: only one tag can be matched per line, so I need to put each tag on a new line. If you want to fix this you need to define a language parser for ctags. You can define more regular expressions though. Idea: hardcore regex for situations with more tags per line, up until a certain limit? I.e. just match a different group each time, i.e. the first tag, than the second etc.

Okay so exuberant ctags (also the later universal ctags ) use POSIX ERE regex, which does not support much and has the quirk that it always matches greedily. See https://www.regular-expressions.info/posix.html. In other words, you really can't have multiple tags on one page.

Even the newer universal ctags says this:

By default it uses the Extended Regular Expressions (ERE) syntax, as used by most engines today; however it does not support many of the “modern” extensions such as lazy captures, non-capturing grouping, atomic grouping, possessive quantifiers, look-ahead/behind, etc. It is also notoriously slow when backtracking, and has some known “quirks” with respect to escaping special characters in bracket expressions.

See: https://docs.ctags.io/en/latest/optlib.html

TODO how can I match both tags AND backreferences or headers? I guess just with an "Or" statement in the regex, right?

My build of exuberant ctags was compiled in 2009 (and I downloaded the latest version).

Another issue with exuberant ctags was that it did not support special characters (utf-8, I guess). E.g. the name Pöggeler was not recognized as a tag.

So... use universal ctags to avoid these issues. It has multiline support. Has regex control flags, e.g. for case insensitivity.

--mline-regex-markdown=/@(\w.*)\s/\1/t/{mgroup=1}{_advanceTo=1start}

What about case insensitivity?

:help tag-regexpr says that ignorecase is used, so set ignorecase in .vimrc .

Apparently CtrlP can also search through your tags file! Does it automatically! Regular CtrlP, then Ctrl-B to search Tags. Or directly: CtrlPTag

To find backreferences, do fuzzy search on current filename with CtrlP. New simpler mapping. Fuzzy matching avoids having to specify the path, either relative or absolute.

--langdef=markdowntags
--languages=markdowntags
--langmap=markdowntags:.md
--kinddef-markdowntags=t,tag,tags
--mline-regex-markdowntags=/@(\w\S*)\s/\1/t/{mgroup=1}{_advanceTo=1start}

Uiteindelijk bleek ik vooral \S te zijn vergeten. Dit forceert de match te stoppen voor de spatie. Daarmee wordt de extra \s ook overbodig. Bovendien is advance to start niet nodig in dit geval, maar mocht ik moeilijkere gevallen hebben later dan is het goed die optie te onthouden. Zie: https://docs.ctags.io/en/latest/optlib.html#multiline-pattern-flags

Dus de uiteindelijke score:

--langdef=markdowntags
--languages=markdowntags
--langmap=markdowntags:.md
--kinddef-markdowntags=t,tag,tags
--mline-regex-markdowntags=/@(\w\S*)/\1/t/{mgroup=1}

mgroup moet je aangeven voor mline modus. YES! Werkt super!

Tips 'n Tricks

Issues with linking to line numbers

When linking to a file, you can append line numbers to open the file at the specified line as such: file.txt:linenumber. However, on Windows the colon is considered to be possible be part of a filename, which prevents the default vim syntax from working.

You can verify this by running set isfname?

A quick fix is to introduce a space between the filename and the colon.

This will not work on Windows: Stiegler

But this will work: Stiegler

A permanent fix is to remove the colon from that list, by setting in your .vimrc:

set isfname -=:

If that causes trouble, add it again with set isfname +=:.

Solution found at Stack overflow

Specifying file numbers breaks GitHub preview of markdown links.

What is a nice way to keep both the Vim reference and a correct Markdown reference? Perhaps I should have the Vim reference as a description of the link, like such:

Stiegler-Aufklarung_Philosophical_Engineering.md:20

Looks like you do not need to give a proper path with gF

If you only provide the filename rather than only a path, gF will start a search and work anyways! This assumes that we cd into the root directory of our notes, which we do with our custom \ww mapping.

I could use this to make links more robust against moving between folders. However, this makes my notes not useable for editors dumber than Vim. Not a problem for me, but if others use this system they should probably give full links. This of course also breaks GitHub preview.

But if I use my system above, I can maintain correct links:

  1. a short reference with line number as a link descriptor
  2. reference with relative path to file without line number

So, in conclusion, this should be my convention:

Stiegler-Aufklarung_Philosophical_Engineering.md:20

TODO convert this in a blog post "A Convention for Combining Vim and Markdown File Linking"

Unique IDs and Timestamps

I keep hesitating about using timestamps. And if using them, if I should always use them.

Pro:

  • Chronological ordering on filesystem
  • Timestamps are unique IDs. Could allow tools for persistence through renaming.

Con:

  • Timestamps make filenames longer and less readable
  • No grouping on filesystem based on names, e.g. papers from the same author, or index pages, or author pages.

Then there's a related issue. Do I use timestamps for structure notes?

For example, otherwise I could group together index files by prefixing them with "index".

Structure

  • No structure with folders, bad bad bad.
  • I will use structure notes instead

Special example: convention for author pages

  • Fill with references to primary literature
  • In secondary literature, refer back to the author page, then secondary references will show up in backlinks