Articles Github Feed

Tagging Jekyll posts with Vim

I’ve moved all of my work notes to a local jekyll instance to make them more maintainable and searchable. One of the things I needed (wanted) to do, was to tag each article with the codebase, this would’ve taken a while manually, but with some vim-fu it becomes very simple.

The filenames look like this (titles truncated):

2018-08-01-dar-133-...
2018-08-01-en-4140-...
2018-08-01-en-4196-...
2018-08-01-en-4291-...
2018-08-01-en-4308-...
2018-08-01-en-4308-...
2018-08-01-en-4356-...
2018-08-01-en-4382-...
2018-08-01-en-4522-...
2018-08-01-en-4610-...
2018-08-01-en-4612-...
2018-08-01-hyp-1108-...
2018-08-01-hyp-1268-...
2018-08-01-hyp-1269-...
2018-08-01-hyp-1465-...
2018-08-01-hyp-1486-...
2018-08-01-hyp-1488-...
2018-08-01-kep-4530-...
2018-08-01-kep-4573-...
2018-08-01-kep-4673-...
2018-08-01-kep-4701-...
2018-08-01-kep-4702-...

conveniently the prefix of the codebase (en, hyp, dar etc…) is already in the filename which makes it even simpler.

In the end I can tag a codebase by opening all files with that prefix in it:

vim *-en-*

Then using the argdo command coupled with normal I can work my magic.

:argdo normal ggotags: enterprise

What this does is:

argdo executes a command on everything in the arglist (in our case that is every file with -en- in the filename).

normal ggotags: enterprise tells us to go to the top of the file, insert a line beneath the cursor and literally type out “tags: enterprise”.

Once that is done, save all of the changes and bask in your tagged posts.

:wall