How to Process Bookfusion Highlights with Vim
Here are my highlights pulled up in Vim:
As you can see, Bookfusion gives you a lot of extra information when you export highlights. First, let’s get rid of the lines that begin with ##
Enter command mode in Vim by pressing esc
. Then type :g/^##/d
and press enter.
Much better.
Now let’s get rid of the color references:`
:g/^Color/d
To get rid of the timestamps, we must find a different commonality between the lines. In this case, each line ends with “UTC”. Let’s match that:
:g/UTC$/d
Where $
matches the end of the line.
Now, I want to get rid of the >
on each line:
%s/> //g
Almost there, you’ll notice there are 6 empty lines in between each highlight. Let’s shrink those down into one:
:%s/\(\n\)\{3,}/\r\r/g
The command above matches newline character n
3 or more times and replaces them with two newline characters /r/r
.
As we scroll down, I see a few weird artifacts from the book conversion to markdown.
Now, I want to get rid of any carrot brackets in the file. Let’s use the substitute command again here:
%s/<//g
Depending on your book and formatting. You may have some other stuff to edit.