Wiki linking and concealing

Something I don’t like of Obsidian‘s Wiki links syntax is that the link is first, and the label second. So:

[[Link|Display Text]]

This breaks the reading flow, because if I write:

Whatever happened [[Daily Notes/Daily Notes 2023-11-01|the other day]]

You inevitably read «Whatever happened [[Daily Notes…» and then see the | character and then I realize, «oh, the text meant to be read was «the other day,» that makes sense now.»

This is no problem while working in Obsidian, because Obsidian will display the link as an HTML link, you read «Whatever happened the other day» and you won’t see the link. That’s great, but I spend most of my time in Vim/Neovim. I would have rather preferred if Obsidian used the other Wiki link format, which is «label first, link second.» Like this:

Whatever happened [[the other day|Daily Notes/Daily Notes 2023-11-01]]

It’s more natural to me. You read «Whatever happened [[the other day» and when you see the |character, you know it’s linking somewhere else. Reading flow doesn’t break.

Then I remembered Vim’s conceal feature. By setting up the proper syntax highlighting rules, Vim can hide the link and show only the label, just like Obsidian!

I thought there might be no need to do this from scratch, maybe there’s a syntax file that, at the very least, parses the link and label. I can go from there. I looked at Wiki.vim’s own syntax highlighting but they don’t parse the text and link part. Same with a Mediawiki syntax file for Vim. Pandoc’s syntax file for Vim doesn’t either.

Change of plans, I had to do it from scratch. I would had to learn two things: how to create new syntax highlighting rules and how Vim’s regular expressions work.

And so I did. I learnt on every little pocket of time I had, meaning, when I was sick with tummy ache at 2 AM, when singing to the kids to sleep, whenever Thais was busy baking, etc. I devoured tutorials and the Vim manual. By the way, Neovim has a better, navigable, manual.

This is how it looks like:

A screenshot of Vim, showing how my concealed Wiki links look.

It works awesome and I feel awesome! I feel like I own Vim at a new level. I’m now thinking on how to leverage this new skill and also the fact that I’m no longer at the whim of a colorscheme being almost perfect if only the Comments color were a bit darker. Now I can tweak it to my liking. And even make some new rules or copy over stuff between syntax files.

And Vim is so powerful! Everything is so very well thought out. It has the experience of years, decades of work. So the syntax highlighting can handle many things and already has solutions for things you might stumble because, in these past decades, many people stumbled with it already and it was solved. Elegantly.

Wiki linking indecision

Something I’m undecided about my personal Wiki is linking from directories. I had to reorganize entries into directories because they started to grow in quantity making navigation cumbersome.

My «problem» now is that linking from, say a Daily Note, looks like this [[../foobar]]. It breaks the natural reading flow. As in:

Yesterday I met [[../../People/Oliver Etchebarne]] and it was nice.

Now, Obsidian does something interesting. If I create a [[foobar]] link, and Obsidian doesn’t find it in the current directory, it tries to find it on every parent directory. This means you can have «clean,» good-looking links that work transparently.

So I was looking on how to make Wiki.vim do the same and there’s indeed a way to do that, I’d need to write a «resolver.»

And here’s where my indecision begins. Is Obsidian going to shape how I write notes? Because otherwise, why not just move my writing entirely to Obsidian? I know the answer to that is, «no, I want to keep using Vim.»

I only use Obsidian on my smartphone, because it’s the better Markdown editor I know of. But I refrain from using Obsidian plugins that require Obsidian to work. If I can’t parse them, read them or replicate their functionality in some capacity, then no.

For example, I use the Templater plugin because it creates files from templates, something I already did with Vim, but I don’t use the DataView plugin, because I’d only see some code declarations and query specifications, making my Wiki dependant on that specific plugin.

So, no, Obsidian will not shape how I do things. Having said that, I’m still undecided on the paths. For now, I’m keeping them relative. I don’t like them but I have writing and stuff to do.

Moving lines in Vim

I’m learning to move ranges of lines in Vim. What I usually did was jump to the starting line, enter Visual Mode, select the lines I want to move, cut, move to the desired location and finally paste.

But Vim has a more efficient, shorter and faster way to do this, no cursor moving at all.

  • Move current line to line after 12: :m 12
  • Move current line to before first line :m 0
  • Move current line to after last tine :m $
  • Move current line to after line with mark a: :m 'a
  • Move range of lines: 5,7m 21 — will move lines 5-7 to after line 21.
  • Move 5 lines starting at current line to after line 21: :.,.+4m 21
  • Move current line 2 lines after current line: :m .+2

And you can return to the line you were with g; (and g, is the opposite).

Looking for a better Wiki

Three years ago, I tried VimWiki but it didn’t convince me. Markdown is not a first-class citizen, but VimWiki’s own syntax. It also uses its own filetype, which made me lose my Markdown customizations. HTML export is only for VimWiki’s syntax, not Markdown. It also stole the Tab mapping I use with UltiSnips.

Then I found Wiki.vim and everything is great. It’s not a filetype plugin, so I can keep my Markdown filetype. It doesn’t overwrite my mappings. It uses Pandoc for export, which is great. It has FZF integration. It has tags, not sure if VimWiki have them too, and I haven’t tried them yet.

I still use it, three years later and now I want to improve some things.

Preach notes

Last Sunday I preached Galatians 1:16-24. Took my time to get the context right.

By the way, I now write my preach notes in Markdown and use them on the Kindle. Printing them has all the wonderful benefits of paper, but I write faster on Vim with all my snippets, filters, dictionaries and stuff. LibreOffice is a fabulous piece of software, but writing as fast as possible is the name of the game.

Fira Code, Miramare, Laravel y DDD

Oh, hey, me está gustando escribir a lo Michael Meeks, me hace recordar la vieja época de los blogs y los diarios en Advogato (que ya no existe, gasp!). Espero que algún día tomemos más consciencia sobre los peligros de las redes sociales y regresemos a los blogs y el control de nuestro contenido.

  • Oliver usa Fira Code como font de programación. Lo estoy probando también y me está gustando. No estoy convencido que los ligatures sea buena idea y Vim no los soporta de todos modos. Me gusta todo lo demás del font, especialmente el cero con slash (y no un puntito al centro como otros fonts). La Sinclair ZX81 tenía el cero así, y para mí es el «cero computadora.»
  • Tengo un nuevo colorscheme favorito de Vim, Miramare.
  • Estoy volviendo a leer la serie de blog posts de Brent Roose sobre proyectos grandes con Laravel y contrastándolo con la arquitectura que he armado yo. A diferencia de Brent, mis modelos son intencionalmente anémicos, porque es antinatural implementar un Domain Model usando objetos de Eloquent. He dicho.
  • Hace tiempo estoy queriendo crear un nuevo blog para escribir exclusivamente de cosas técnicas y programación. Como que ya debería darle prioridad, ¿verdad?
  • Y acabo de recordar que tengo en deuda escribir un blog post sobre qué me gusta de Laravel.