Option to show line numbers in editor

The "codeMirrorOptions" API mentioned above was experimental and has been removed. It's not clear yet how to modify this kind of settings with the new plugin system, but we'll get to it at some point.

Quick hack in userchrome.css:

	counter-reset: line;

	counter-increment: line;
	content: counter(line);
	width: 2rem; /*  Adjust if you have lot of lines, big numbers */
	display: inline-block;
	padding: 0 0.5em;
	margin-right: 0.5em;
	border-right: 1px solid #DDD;
	color: #888

Looks a bit strange on long, wrapped lines, but might be usable.


So, I noticed that CalebJohn recently added support for code mirror content script plugins to Joplin. Spent some time on it and was able to create the line number enablement plugin :slight_smile:
Anyone else interested can get it from here: Release 1.0.0 · shantanugoel/joplin-plugin-cm-linenumbers · GitHub

Code is at: joplin-plugin-cm-linenumbers/src at main · shantanugoel/joplin-plugin-cm-linenumbers · GitHub


Maybe you want to add your plugin to the #plugins category.

1 Like

awesome thank you!

Can this be enabled to show line numbers only within a "code fence"?
For example...

$code = '
public static extern IntPtr VirtualAlloc(IntPtr lpAddress, uint dwSize, uint flAllocationType, uint flProtect);

I'd love to be able to reference a specific line of code.

I created a pull request to make the displayed line numbers relative:)

1 Like

It would be nice to have an option for that. An example how options can be created/used in a plugin is in Plugin: Note Tabs


does it work with latest version? I installed it, but doesn't seem to work. Can you please add some instruction on the readme.md file?