"Edit with external editor" option

jo
john1013
Posts: 47
Joined: Sun May 22, 2016 8:09 am
Platform: Windows

Thu Mar 12, 2020 6:38 pm Post

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.

User avatar
kewms
Posts: 6057
Joined: Fri Feb 02, 2007 5:22 pm
Platform: Mac

Thu Mar 12, 2020 8:00 pm Post

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

Katherine
Scrivener Support Team

jo
john1013
Posts: 47
Joined: Sun May 22, 2016 8:09 am
Platform: Windows

Thu Mar 12, 2020 8:21 pm Post

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

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

User avatar
devinganger
Posts: 1983
Joined: Sat Nov 06, 2010 1:55 pm
Platform: Mac, Win + iOS
Location: Monroe, WA 98272 (CN97au)
Contact:

Thu Mar 12, 2020 10:02 pm Post

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..,.
--
Devin L. Ganger, WA7DLG
Not a L&L employee; opinions are those of my cat
Winner "Best in Class", 2018 My First Supervillain Photo Shoot

User avatar
kewms
Posts: 6057
Joined: Fri Feb 02, 2007 5:22 pm
Platform: Mac

Thu Mar 12, 2020 10:45 pm Post

devinganger wrote: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
Scrivener Support Team

jo
john1013
Posts: 47
Joined: Sun May 22, 2016 8:09 am
Platform: Windows

Fri Mar 13, 2020 10:46 am Post

@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.

br
brookter
Posts: 2081
Joined: Wed Mar 18, 2009 12:22 pm
Platform: Mac

Fri Mar 13, 2020 12:09 pm Post

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.)

jo
john1013
Posts: 47
Joined: Sun May 22, 2016 8:09 am
Platform: Windows

Fri Mar 13, 2020 12:26 pm Post

@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.

User avatar
lunk
Posts: 3978
Joined: Wed Aug 21, 2013 4:24 pm
Platform: Mac + iOS
Location: Sweden 64° N

Fri Mar 13, 2020 12:42 pm Post

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.
I am a user, writing non-fiction and science, using:
* Mac Scrivener 3 on a Macbook 12”, MacBook Pro 13”, and iMac 27”, all running Mojave.
* iOS Scrivener 1 on an iPhone 11 Pro, iPad Air 9.7”, and iPad Pro 12.9”, all running the latest iOS

br
brookter
Posts: 2081
Joined: Wed Mar 18, 2009 12:22 pm
Platform: Mac

Fri Mar 13, 2020 12:46 pm Post

@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.
Last edited by brookter on Fri Mar 13, 2020 12:56 pm, edited 1 time in total.

br
brookter
Posts: 2081
Joined: Wed Mar 18, 2009 12:22 pm
Platform: Mac

Fri Mar 13, 2020 12:55 pm Post

@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.

User avatar
lunk
Posts: 3978
Joined: Wed Aug 21, 2013 4:24 pm
Platform: Mac + iOS
Location: Sweden 64° N

Fri Mar 13, 2020 1:05 pm Post

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...
I am a user, writing non-fiction and science, using:
* Mac Scrivener 3 on a Macbook 12”, MacBook Pro 13”, and iMac 27”, all running Mojave.
* iOS Scrivener 1 on an iPhone 11 Pro, iPad Air 9.7”, and iPad Pro 12.9”, all running the latest iOS

jo
john1013
Posts: 47
Joined: Sun May 22, 2016 8:09 am
Platform: Windows

Fri Mar 13, 2020 1:09 pm Post

lunk wrote: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.


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

lunk wrote: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.


Joplin somehow knows it and handle such case.

br
brookter
Posts: 2081
Joined: Wed Mar 18, 2009 12:22 pm
Platform: Mac

Fri Mar 13, 2020 2:35 pm Post

lunk wrote: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...


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.

User avatar
kewms
Posts: 6057
Joined: Fri Feb 02, 2007 5:22 pm
Platform: Mac

Fri Mar 13, 2020 4:23 pm Post

lunk wrote: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.


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

Katherine
Scrivener Support Team