Change the indent used by Breadcrumbs plugin from 2 spaces to tab

The command Breadcrumbs: Copy a Local Index to the clipboard will generate a hierarchical list.
The indent used in this hierarchical list is the space, i.e. adding 2 spaces increases a level of indent.

However, in the obsidian, the indent used for hierarchical list is configurable. And in my case, the indent used is the tab, i.e. adding 1 tab will increase 1 level of indent.

Therefore, here comes the problem, when I generate a long list with Breadcrumbs, I need to manually replace the indent of almost every item from 2 spaces to 1 tab.

The alternative method that I used now is patching the main.js of the Breadcrumbs plugin.

  1. locate the following function in the main.js of Breadcrumbs plugin. The main.js will be at path_to_your_vault/.obsidian/plugins/breadcrumbs/
function createIndex(allPaths, asWikilinks) {
    let index = "";
    const copy = lodash.cloneDeep(allPaths);
    const reversed = copy.map((path) => path.reverse());
    reversed.forEach((path) => path.shift());
    const indent = "  ";
    const visited = {};
    reversed.forEach((path) => {
        for (let depth = 0; depth < path.length; depth++) {
            const currNode = path[depth];
            // If that node has been visited before at the current depth
            if (visited.hasOwnProperty(currNode) &&
                visited[currNode].includes(depth))
                continue;
            else {
                index += `${indent.repeat(depth)}- ${asWikilinks ? makeWiki(currNode) : currNode}\n`;
                if (!visited.hasOwnProperty(currNode))
                    visited[currNode] = [];
                visited[currNode].push(depth);
            }
        }
    });
    return index;
}
  1. replace the line:

const indent = " ";

with

const indent = "\t";
3. save main.js and reload the Obsidian.

1 Like