# Rene's SublimeText for Zettelkasten - Package, Talk and more

• OMG!!! Thanks for sharing the trade secret

I am not sure about hidden temporary files in the context of SublimeText: Why not just create a new view ( = buffer) in a new tab with those contents (clickable, understood!)? Doesn't "litter" your directory with dynamically created (think ugly .~0273645.search.txt). Having one .search.txt allows for only 1 search result tab. Why not have as many as you want in dynamic buffers? If you want to make them permanent, just save them. Am I missing something?

• I don't know Sublime; I was thinking about piping the search results to the same buffer all the time so you get something like the permanently visible list of notes from nvALT. If you do not need a permanent file handle for that and can always write to the same buffer, that might not even be necessary.

Author at Zettelkasten.de • https://christiantietze.de/

• @mediapathic I have just commited a patch: when the plugin is loaded it prints out whether it uses ag or not. If it doesn't use ag then it's because ag --help could not be executed.

• @ctietze Hmmm, I think I have a problem understanding what you mean. I don't really know nvALT. Do you mean something like a permanent "find results" tab/view/window that gets reused every time? Sounds sensible to me. Instead of opening a new tab with every search, it could be re-used -- so you could put it somewhere handy and it just updates.

I think that can be done in the plugin without an auxiliary file. I am thinking whether it makes sense to go through the trouble. If it's a file-less dynamic view, it probably doesn't survive a restart of SublimeText, for instance. Not sure whether this is a problem, though.

A .search.md (syntax coloring for free) could be handy. On the other hand: Having to write the search results captured from ag into a file afterwards feels a bit backwards. Making ag write it itself or maybe using some pipe operator (if possible without the use of a script (ref python's subprocess module)) would probably make more sense.

I'll fiddle around with it and work something out

Thanks for all the great suggestions!

• regexes really can be a pain. at the moment I am happy with

(?<=\s|^)(?<!)(#+[^#\s.,\/!$%\^&\*;:{}'"=~()]+) (https://regex101.com/r/vf5dSY/6) I don't want it to capture parts of URLs, so I require an (?<=\s|^) and I also kept @ctietze 's (?<!). For some reason, @ctietze, your mega regex causes ag to cut off after an umlaut . @toolboxen as for \w based approaches for capturing the tag's text, this fails for me on German umlauts like in plankonformität. I will stick with the above until complaints come in • That permanent search results file turns out to be an awesome feature!!! I only realized how powerful it is once it was implemented. That's like having a little navigation window that just stays where it is... and always shows you want you want . I prefer it over the overlay solution. It's one of the most useful features - ever . It's now used for the tag list, search for tagged notes, and search for referencing notes (friends); however, only if ag is installed. Tag list: Searching for tagged notes: Searching for friend notes: • @rene said: @mediapathic I have just commited a patch: when the plugin is loaded it prints out whether it uses ag or not. If it doesn't use ag then it's because ag --help could not be executed. Ok! It says it is not using ag. However, I can execute ag --help in a terminal window. It's in /usr/local/bin, fwiw. • OK, this is strange, @mediapathic . But maybe we can work it out. As you are an Archive Beta tester I assume you're on OS X and not Linux, right? For some reason, your SublimeText seems not to know about the path /usr/local/bin. This can happen if you have SublimeText running and then install homebrew (followed by ag, ...). Re-starting SublimeText would fix that. On Ubuntu Linux, I had a similar problem when starting a program via the graphical launcher. I set my PATH in .bashrc -- but that is only loaded by bash --> in the terminal. Not necessarily by the graphical launcher. Maybe something similar is going on on your system. One workaround is having a plugin setting that specifies the path to ag. • @mediapathic I have just committed the workaround. If it's only a weird PATH issue, it should work for you now: If ag cannot be found the first time, then the setting path_to_ag is queried. That defaults to /usr/local/bin/ag. • edited November 2017 So here's my trade secret: the hashtag regex... wow!!! That is a gnarly juicy regex regexes really can be a pain 100% agreed That's like having a little navigation window that just stays where it is... and always shows you want you want Very cool. I like the feature a lot. @mediapathic I ran into similar issue before using brew. You can try brew link the_silver_searcher to make sure it's properly symlinked. If you still have trouble try brew doctor and follow the instructions it provides. Another issue is perhaps root user owns /usr/local/bin which might cause issues with calling ag from another app. So you can try following some of the trouble shooting steps in these two links: • I put in some basic support for "Overview note expansion and refresh" - via the command palette (finally! ) It expands lines with 1 or more links into: <!-- ! [[note_id]] --> contents of the note <!-- (End of note note_id) -->  There is a 2nd command to refresh if source notes have changed. However, if you remove the 2nd ! in <!-- !, or remove the comments for a note altogether, then this part won't get refreshed. This is might read complicated, it's better to watch • Sweet! I see you're scripting your way forward to complete the "knowledge cycle" pretty quickly Looks great. I'd be super happy if the simple outline format we propose would be recognized, too, as in: https://zettelkasten.de/posts/zettelkasten-outline-script/ You can actually use the script there, if you want, although I still have to add the new hotness, [[...]] link recognition, if I remember correctly. The result after "transclusion" (I think that's the term MultiMarkdown uses to include files in other files) looks very much like what we proposed back then, but we are actually collecting links to notes manually in outline files/lists first. The format is super simple, it's just a Markdown list of links: - [[201711121258 note title]], with annotation and explanation why this was included after the brackets - §201508120522 another note. Annotation after the first period (.), if any  That's the overview note we think people should keep in their archives for most cases. It's useful to, well, to have overviews But the transcluded result is a step out of note management towards writing, so I'd create a new buffer in a separate tab/window for that. Author at Zettelkasten.de • https://christiantietze.de/ •  - [[201711121258 note title]], with annotation and explanation why this was included after the brackets - §201508120522 another note. Annotation after the first period (.), if any  That's the overview note we think people should keep in their archives for most cases. @ctietze Well, I can try to support this format: [[201711121258 note title]], but it is not in line with the rest of the plugin that is built on [[201711121258]] note title. Actually, if you use the plugin, type [[ to insert links, etc, the current format [[201711121258]] is what you are going to end up with. If you use [[201711121258 note title]] all the other features like highlighting etc won't really work anymore. In regular notes [[201711121258]] is used everywhere so it seems inconsistent to use a different format only in overview notes. The plugin does not impose any other formatting of overview notes or notes-to-be-transcluded , though: * any line containing a [[201711121258]] note link will be replaced by the contents of the note. * even more than one [[201711121258]], or two [[201711121258]] links are supported. Line will be replaced by two note-content blocks.  But the transcluded result is a step out of note management towards writing, so I'd create a new buffer in a separate tab/window for that. That's already the case, though probably hard to see in the animation: Upon expansion (with transclusion) a new, unsaved, untitled tab is created with the result of the operation. Refreshing also happens within this tab. • Aha, that's good to know! Sorry I missed that detail Author at Zettelkasten.de • https://christiantietze.de/ • edited November 2017 §201711111709 links are fully supported in the plugin now. Let me repeat: §201711111709 links are fully supported in the plugin now!!!!!!!! They can be clicked, appear in results of notes referencing note id 201711111709, are transcluded at overview note expansion, etc. However, [[ -> select note to link to, does not support this link style. It will produce [[201711111709]] or [201711111709] depending on settings. When transcluding, the link style gets carried over into the surrounding comment, eg: <!-- ! §201711111709 note title -> Refreshing (re-transcluding) the above works as well. Only for expansion of 'legacy' overview notes, [[201711111709 note title]] ... is supported --> note 201711111709 will be transcluded. Such links are not highlighted and if you click on them, the [[create a new note by title link]] mechanism kicks in. The latter can possibly be fixed if the plugin checks the first word for being a [0-9]{12} and highlighting stops caring about closing brackets. Must think about possible side-effects and try... But so far, your (@ctietze's) use case is supported Here is "photographic proof" click to enlarge • @rene said: @mediapathic I have just committed the workaround. If it's only a weird PATH issue, it should work for you now: If ag cannot be found the first time, then the setting path_to_ag is queried. That defaults to /usr/local/bin/ag. I am pleased to report that it works now! However, I should also note that for reasons unrelated to our discussion here I nuked my entire sublime install and started from scratch, so... maybe that fixed it instead? Sorry to leave you with less data for solving future issues, but yay it works now! Also, thank you again for your work on this. It's making sublime an actually useful tool for me as opposed to something with which I merely fight to install plugins. • @mediapathic, glad that it works now. No worries about erasing forensics information; we'll address future issues as they (might) show up. Also, thank you again for your work on this. It's making sublime an actually useful tool for me as opposed to something with which I merely fight to install plugins. So you're not working for your tool anymore but the tool is working for you. That's how it should be • edited November 2017 Heeeey who wants edge cases? I got edge cases! ### First thing: So, I'm still having a problem with the regex on tags. If I do #!, the tag list shows up like:  #clocks #clocksnotes #clockstxt  etc, as it should be, no commas. But! if on a file that looks like this: --- tags: @project, §§, #clocks, #clocksnotes, @active uid: 201706192201 ---  I do ctrl-enter on #clocksnotes get a result list that only includes files that include #clocksnotes, with the comma. ### Second thing: I'm still getting these results in the generated tag list: #28\ #73_ #digitalhealth” #digitalhealth”<  I don't actually mind these at all, they are notes that I should fix anyway. But I just wanted to include them as data points for the ever-evolving regex. ### Third thing: the tag #§§ shows up as not red on the generated tag list. Again, not a problem, but thought you should know. [EDIT] Minor bug report: If I have a Friend Notes list in the search result window, and I #?, the search result window gets populated with the tag list. And Minor Feature Request: How hard would it be to ensure ctrl-enter results wind up in the "other" pane (assuming I'm using Origami)? It's a minor irritation to have to move them over, when I'm using the search results as a working documents list. This may be more difficult than it's worth. Thanks! Post edited by mediapathic on • @rene said: I put in some basic support for "Overview note expansion and refresh" - via the command palette (finally! ) Just a quick note to say I'm playing with this, and it does not in fact get caught in an infinite loop and crash when you include a note's reference in itself! • @mediapathic said: Heeeey who wants edge cases? I got edge cases! Yeey, edge cases! Who doesn't love edge cases ? Bring them on ! ### First thing: ... I do ctrl-enter on #clocksnotes get a result list that only includes files that include #clocksnotes, with the comma. That should be fixable and fixed! ### Second thing: I'm still getting these results in the generated tag list: #28\ #73_ #digitalhealth” #digitalhealth”<  I don't actually mind these at all, they are notes that I should fix anyway. But I just wanted to include them as data points for the ever-evolving regex. The ever-evolving regex is thankful you provide food for it to grow! ### Third thing: the tag #§§ shows up as not red on the generated tag list. Again, not a problem, but thought you should know. Aaah, another fixable one . [EDIT] Minor bug report: If I have a Friend Notes list in the search result window, and I #?, the search result window gets populated with the tag list. Huh, that's a bug? #? is supposed to bring up the tag list. Since we now use externalized search results ( results in (always the same) file), this is the desired behaviour. One could argue that tag list and friend list should be separate files... But I find it very handy to only have one search result tab... And Minor Feature Request: How hard would it be to ensure ctrl-enter results wind up in the "other" pane (assuming I'm using Origami)? It's a minor irritation to have to move them over, when I'm using the search results as a working documents list. This may be more difficult than it's worth. I have no idea what you're talking about. Probably because I don't know Origami . I should fix that lack of knowledge. If I guess correctly, what you suggest should be doable but I haven't verified this ... yet. Thanks! You're welcome and thanks for your suggestions and issue reports! • @mediapathic said: @rene said: I put in some basic support for "Overview note expansion and refresh" - via the command palette (finally! ) Just a quick note to say I'm playing with this, and it does not in fact get caught in an infinite loop and crash when you include a note's reference in itself! Yeah, it does not descend into links within linked notes. • ### Second thing: I'm still getting these results in the generated tag list: #28\ #73_ #digitalhealth” #digitalhealth”<  I don't actually mind these at all, they are notes that I should fix anyway. But I just wanted to include them as data points for the ever-evolving regex. If you don't mind, could you share the lines causing this? I would think those are lines starting with #..? [EDIT] Minor bug report: If I have a Friend Notes list in the search result window, and I #?, the search result window gets populated with the tag list. Now I got you! Yep, that's a bug! • @mediapathic • First thing should be fixed now • Second thing should be a bit improved: #28 #73_ #digitalhealth • Third thing is fixed • @mediapathic #? now won't destroy your friends anymore • BTW just in case everybody missed it : §201711142004 style note links are now supported, too. If anyone is brave enough to try it out on their archive . §201711142004 links won't be created when inserting a link but they will be recognized, highlighted, can be followed, etc. • edited November 2017 @toolboxen just a quick question if you don't mind: a fellow Windows SublimeText user reported that [[ doesn't work for him. We traced it back to: command: insert_snippet {"contents": "[$0]"}


in the console.

Did you also encounter this problem? I am thinking of adding some ALT+[ or something to the Windows keymap if this is a Sublime-Windows problem.

Scary stuff at https://github.com/SublimeTextIssues/Core/issues/392

• @rene said:
I have no idea what you're talking about. Probably because I don't know Origami . I should fix that lack of knowledge. If I guess correctly, what you suggest should be doable but I haven't verified this ... yet.

Oh, Origami is just a package that allows for easier manipulation of panes. I guess what I mean is "I'd like if you could implement this, and you might be able to cheat by piggybacking on what Origami is already doing."

Thanks!

You're welcome and thanks for your suggestions and issue reports!

Everything else seems to be working as reported! Thanks for the quick turnaround!

Question: I would like to change the template for the header that is output when a new file is created. Can you tell me where to find that?

• And now that I've said that, suddenly creation of a new note with [[ doesn't work. I get the popup menu, but nothing is written when I select one. I've uninstalled the packages I installed since (Academic Markdown and Markdown Preview), uninstalled and reinstalled your package, and no luck. Any ideas?

• @mediapathic said:
And now that I've said that, suddenly creation of a new note with [[ doesn't work. I get the popup menu, but nothing is written when I select one. I've uninstalled the packages I installed since (Academic Markdown and Markdown Preview), uninstalled and reinstalled your package, and no luck. Any ideas?

Yes, sorry. Yesterday I had renamed all commands of the package to make them start with zk_ to avoid potential name clashes with other packages. While I had updated all config files, I apparently forgot to change all relevant lines in the plugin code that reference those commands.

It is fixed now. Sorry for the inconvenience.

• @rene said:

@mediapathic said:
And now that I've said that, suddenly creation of a new note with [[ doesn't work. I get the popup menu, but nothing is written when I select one. I've uninstalled the packages I installed since (Academic Markdown and Markdown Preview), uninstalled and reinstalled your package, and no luck. Any ideas?

Yes, sorry. Yesterday I had renamed all commands of the package to make them start with zk_` to avoid potential name clashes with other packages. While I had updated all config files, I apparently forgot to change all relevant lines in the plugin code that reference those commands.

It is fixed now. Sorry for the inconvenience.

Hooray, not my fault!

Thanks.