Moving from Roam to Obsidian: Convert whitespaces into tabs

I’m not sure if I’m the only one who faced this problem but the markdown export from Roam turned all the tabs in my notes into two consecutive whitespaces.
While tabs vs. whitespaces might be a purely personal choice, this also caused a problem for one of the css snippets I found which displays relationship lines between different bullet points. This snippet depends on tabs, not whitespaces.

In order to solve this problem, I created two small sed-scripts that convert all two consecutive whitespaces into one tab. In order to do this, you need to run both commands after another in the shown order. There is one small issue where the first command creates two tabs instead of just one. The second command then replaces all consecutive two tabs with one tab.

find . -type f -name '*.md' -exec sed -i '' -e 's/ /\t/g' {} \;
find . -type f -name '*.md' -exec sed -i '' -e 's/\t\t/\t/g' {} \;

The two commands worked perfectly for me and I hope that I can help more people by posting the snippet here. Just make sure that you have a backup of your vault in case anything goes wrong.

1 Like

Your first command should have two whitespaces intead of one:

find . -type f -name '*.md' -exec sed -i '' -e 's/ /\t/g' {} \;

Anyway it’s solved the problem, and I really appreciate that.