Obsidian-Code-Styler icon indicating copy to clipboard operation
Obsidian-Code-Styler copied to clipboard

Feature Request: Allow line number specifications (`#START-END`) in local file references

Open Thundercraft5 opened this issue 7 months ago • 0 comments

Summary

The file referencing feature is excellent! Currently we can only reference an entire file, I propose a syntax at the end of a link so we may specify which line numbers/columns we wish to include.

The format is [[PATH/TO/DEST#START-END]]

Basic example

Give a file at [[path/to/dest/test.js#2-8]] with the following content:

async function test(param) {
	try {
		await return fetch("https://test.com");
		return true;
	} catch(e) {
		console.error("Failed!", e);
		return false;
	}
}

We would get displayed:

	try {
		await return fetch("https://test.com");
		return true;
	} catch(e) {
		console.error("Failed!", e);
		return false;
	}

In our example markdown file:

```reference
file: "[[path/to/dest/test.js#2-8]]"
```

Motivation

This feature would allow for more fined-grained control for what content we include in codeblocks.

Thundercraft5 avatar Jul 20 '25 23:07 Thundercraft5