Trilium: Edit in external editor

Created on 5 Dec 2019  路  9Comments  路  Source: zadam/trilium

Hi

I think that being able to edit the current note in an external editor can be very useful especially for Markdown since the Trilium does not render .md at all beside showing it as text.

Joplin provides this functionality, Ctr-E opens the text in an external editor of choice, and the content is updated when the user saves the page in that editor.

Trying to edit a file externally and bringing it back is quite a bit of involved atm.

thanks

Hard Under Debate Enhancement

Most helpful comment

for the code notes it would be soooo practical !

It would even be relatively simple to implement (at least on linux):

  1. You press let's say Ctrl+Shift+E to edit current note.
  2. Trilium creates a tmpfile containing note's content, then opens it with user's favorite editor.
  3. as soon as the editor is closed, the note is rewritten with tmpfile's current content.
  4. tmpfile is removed

I have a shortcut on my system which opens clipboard buffer in vim to edit it before pasting it somewhere, so from now i use it to edit most of my code notes, but it's less efficient, because i need to:

  1. selected all note's content (Ctrl+A)
  2. copy (Ctrl+C)
  3. press my custom shortcut to open clipboard in vim
  4. edit the file
  5. delete note content
  6. press Ctrl+V (paste) to write my vim-edited clipboard content

All 9 comments

Hmm, that would be very useful also for file attachments (e.g. word documents etc.)

I did not think about the attachments, that is a really good point too.

for the code notes it would be soooo practical !

It would even be relatively simple to implement (at least on linux):

  1. You press let's say Ctrl+Shift+E to edit current note.
  2. Trilium creates a tmpfile containing note's content, then opens it with user's favorite editor.
  3. as soon as the editor is closed, the note is rewritten with tmpfile's current content.
  4. tmpfile is removed

I have a shortcut on my system which opens clipboard buffer in vim to edit it before pasting it somewhere, so from now i use it to edit most of my code notes, but it's less efficient, because i need to:

  1. selected all note's content (Ctrl+A)
  2. copy (Ctrl+C)
  3. press my custom shortcut to open clipboard in vim
  4. edit the file
  5. delete note content
  6. press Ctrl+V (paste) to write my vim-edited clipboard content

as soon as the editor is closed, the note is rewritten with tmpfile's current content.

This is the hard part - it is possible to know when the editor is closed when the editor is spawned as a new process from trilium. But in many use cases it would make more sense to open it in an existing process (e.g. new tab in VS Code). Also to spawn it as a process the trilium would have to know exact command to run, I don't think it's possible to use the native OS application selection dialog ...

Why not take a look at Joplin's code to see how they did it there? It works great with it. I realize that Joplin is a flatfile system but still it might be helpful. It is an Electron app too, so maybe the code can be used easily.

I use that functionality in Joplin on WIndows and Linux, and I have not met a glitch with it. It also does not block Joplin during that time.

But in many use cases it would make more sense to open it in an existing process (e.g. new tab in VS Code).

My knowledge of windows internals is very bad. But for linux at least you can list processes having an active file descriptor to a file (lsof command). So a solution might be to wait until the file is not anymore open by a process

But really it's harder to realiably implement.

Hope can be integrated the editor (https://github.com/nhn/tui.editor), feel it is a more modern editor, user experience is very good, support for markdown is better, and supports uml syntax, etc.

Hope can be integrated the editor (https://github.com/nhn/tui.editor), feel it is a more modern editor, user experience is very good, support for markdown is better, and supports uml syntax, etc.

Or https://github.com/pandao/editor.md

This would be useful, I personally have an entire year of notes made in Typora (uses github flavoured markdown) and I can't really refer to / edit them in trillium, being able to open them in Typora would help

Was this page helpful?
0 / 5 - 0 ratings