"Edit with external editor" option

It will be great to have an option to edit current text in the external editor. For example, in Sublime Text or Vim.

Scrivener has good organizational capacities, but it’s not convenient to write the text.

Multiple cursors? No.
Regular expressions? No.
Automatically recognized clickable hyperlinks? No.
To jump to specific line or word? No.
And so on.

The proposed feature will fix all these issues.

You can see the reference implementation in the open-source note-taking app Joplin, an Evernote clone. The notes are stored as a sqlite database. When you click “Open in external editor” button, your default text editor opens with a filename like hjvehg3yutr363r3dvbhjdvd (that is, random). When you save and close the file, it will be removed from the disk, and the changes will be written to the database.

You can use the Sync with External Folder mechanism for this purpose.

Katherine

@kewms, sorry, it’s not an option.

Even the manual copy-and-pasting back and forth is better than this.

I would really like to know how writing in a text-only editor (vim) is supposed to be a good solution for an RTF-centric project format and solution…,.

This is a valid point. Scrivener’s native format is RTF, so working back and forth between Scrivener and a plain text editor is always going to introduce additional complexity, regardless of the mechanism used to transfer the actual files.

I suggested the Sync with External Folder option precisely because it is designed to work around the limitation, as it can sync in plain text format if desired.

Katherine

@kewms, here is how I see it:

The user have “Open in external editor” button on the toolbar. The user can choose whether the files should be opened as plain text or as rich text.

In the former case:

1.The original rich text file should be converted to TXT
2. Then, the TXT file should be opened in the app associated (on the system-wide level) with TXT files. For example, in Sublime Text
3. After you closed the TXT file, the saved changed should be written back to the original rich text file. The TXT should be deleted.

In the latter case, the file will be opened in the app associated (on the system-wide level) with rich text files. For example, in Microsoft Word.

This is much better than “sync with external folder”.

  • You don’t need to have this directory anywhere.
  • You don’t need to be afraid that some of the texts will disappear. (Generally, syncing is a dangerous thing.)
  • It simply much more convenient and intuitive. Less things to remember, less mouse clicks, no need to switch between Scrivener and file manager.
  • It is easier to stay focused. An important thing for writers.

The concept of automating cut and paste for external edit has been around for years - I’ve been using it off and on in OSX for the last ten years at least —but it’s only “much better than external sync” if you ignore the additional benefits which external sync brings.

With external sync I know that any inline comments or footnotes I make will be available in both Scrivener and in Vim/Emacs and vice versa – in the text editor they will appear, or I can create them, as ((comments)) or {{footnotes}}. You can’t do that with simple automated copy and paste.

With external sync I can work on a project on my laptop or iOS without having to have a copy of Scrivener on that machine. You can’t do that with simple automated copy and paste: you have to have Scrivener open alongside your editor. The chances of things going wrong are small, because snapshots are taken before and after each sync.

So, external sync is a valid and helpful tool to have and it shouldn’t be dismissed.

But simple automated copy and paste has its uses too, of course, and not just in Scrivener. You do this on the Mac with macros from tools like Keyboard Maestro, set to a shortcut, which then runs the copy to temporary file and paste back routine - it looks like Joplin is simply using the same approach.

The benefit of having a third party tool for this is that it works everywhere you write, not just in Scrivener. A quick search suggests that Autohotkey can do something similar on Windows: https://autohotkey.com/board/topic/78526-edit-everywhere-with-vim/ It’s a free program, so it may be worth checking out.

In any case, it’s a simple concept so presumably there will be other ways of doing the same thing. The amount of users who know enough to want to use Vim and Emacs everywhere is probably quite small: would it be worth Scrivener developer effort when Vim and Emacs users are likely to be expert enough to be able to find other ways?

(BTW, Version 3 of Scrivener does have regular expression search – in ICU format – and there is an equivalent of the vim * command as well as automatically recognisable internal links.)

@brookter No, I’m not Vim/Emacs zealot. Actually, I use Sublime Text and Word a lot. What I’m talking about is the option to edit the text using the familiar app. For some person it would be Sublime Text, for another person it would be Vim, and somebody will prefer Word. I tried to make it clear in my previous post.

1 Like

The part that is not included in your post is what happens when you are done. The external editor would then need to save the manipulated document back into the correct place in the project folder (or package, as it is on a Mac) and possibly also make changes to the scrivx file or project meta data. But the external editor doesn’t know that the document belong to a Scrivener project. And Scrivener wouldn’t know that you decided to quit the external editor.

And it couldn’t be used in scrivenings mode, which would probably create a lot of posts in here from people asking why the “Edit with external editor” menu item is greyed out.

And what about split screen mode? It wouldn’t work there either.

@john,

Indeed. Vim and Emacs are the usual suspects because text navigation and manipulation are so much better (even than most other text editors) that for some it worth the hassle of using an external editor. If such things matter then you’re probably using markdown for formatting anyway, which is fine as Scrivener can deal with it, but it’s another deviation from the mainstream, and therefore even less of a priority for a developer with limited time. That’s why I suggested a third party macro – not only does it work everywhere, but it means you don’t have to wait for something which may never arrive.

@lunk,

These things usually work by simply automating a series of cut and pastes, bound together by a script to open a temporary file, from which the new text is pasted back into the same document in the still open Scrivener. They don’t write directlty to a underlying file.

It can be useful – say if you want to do a complicated set of regexp replacements in vim on a particular document – but there are downsides to them, such as dealing with lost formatting and the need to guard against lost work, so it can often be more trouble than it’s worth. After external sync arrived, I found it was a much more robust useful general tool.

Yes, but that kind of simplified copy-and-paste is not really what the OP wants, is it?
And scrivenings mode would still be a problem…

Yes, may be. I cannot say for sure because I’m not very advanced user.

Joplin somehow knows it and handle such case.

From his description, I think that’s what is involved, but I could be wrong, of course.

Either way, I completely agree there are downsides to it with Scrivenings, internal links etc etc.

Exactly. This is precisely why this function doesn’t already exist.

Katherine

I’m sure you can understand why accommodating people who don’t want to use Scrivener is not a particularly high Scrivener development priority.

Katherine

Exactly. This is precisely why this function doesn’t already exist.

As I said, Joplin somehow do it.

I’m sure you can understand why accommodating people who don’t want to use Scrivener is not a particularly high Scrivener development priority.

Scrivener has very weak capacities to edit the text. What I propose is to eliminate this disadvantage by creating a bridge to the app that can do this job better.

If you can add the good text editing capacities to Scrivener itself, it will be even better. But it will be harder to accomplish.

I’m not familiar with Joplin, but a quick look at their website suggests some important differences.

  • Joplin notes are in Markdown format, which eliminates the whole RTF/plain text conversion issue that Scrivener faces.

  • Joplin notes are independent entities. There doesn’t seem to be anything like Scrivener’s understanding that all documents are part of a “project,” and that maintaining relationships between them matters. This, in turn, drives a lot of Scrivener’s metadata.

Katherine

What is this even mean? :mrgreen:

I think you’re trying to use Scrivener as a tool for something that it isn’t intended for.
Maybe you can try Joplin? :mrgreen:

This sort of silly hyperbole does your argument no good whatsoever, you know.