vkbo / novelWriter

novelWriter is an open source plain text editor designed for writing novels. It supports a minimal markdown-like syntax for formatting text. It is written with Python 3 (3.9+) and Qt 5 (5.15) for cross-platform support.
https://novelwriter.io
GNU General Public License v3.0
2.03k stars 102 forks source link

Keyboard shortcut to Move Tree Item to different folder #674

Open protostork opened 3 years ago

protostork commented 3 years ago

Wonderful software, it works very well.

A small feature suggestion: there seems no way to move items in the tree into another folder with the keyboard (besides dragging and dropping with the mouse).

Suggested potential / partial solutions:

Either of these would really help with a keyboard-driven workflow.

vkbo commented 3 years ago

Thanks!

That's a good idea. I mostly use drag and drop for this, so haven't really given it much thought.

I suppose this would work:

Moving between root folder will still need to be drag and drop as the drag and drop routine does a lot of checking whether it's allowed or not.

protostork commented 3 years ago

Thanks for your super-fast response, that would be fantastic!

The above that you describe would work well. One piece of tiny feedback:

I also had two other tiny and more long-term 'stretch' goals / ideas along similar lines for even better keyboard-driven workflow, though these are probably a little trickier to implement.

Global key shortcuts for move tree item?

Is there any way to make the 'tree movement' keyboard shortcuts accessible from the document editor and all other focused panes? This would likely require different shortcuts to ctrl+shift+arrow or ctrl+arrow, since those are used in the text-editor. It could perhaps use vim-style keys, like ctrl+shift+j/k/h/l, to move the currently selected tree item down/up/left/right.

The advantage to that approach would be that it would make the restructuring or moving around of sections even faster, without requiring changing the focus with alt+1 first, and then moving the focus back to the editor with alt+2.

Shortcuts to move items in outline mode?

I imagine this would require more significant re-architecting, but it would be incredible if eventually items in the outline mode could also be moved up, down (in the hierarchy) and 'left' and 'right' (which in novel mode, could change the header level of a section). This would also have to move all 'child' content (including child headers and normal text) around the hierarchy.

Again, I'm not sure if the current code base is conducive to it, but it would make the outline view significantly more useful (much like outline mode in Microsoft Word, for instance).

vkbo commented 3 years ago
  • I would have is to keep the hotkeys to move left and right similar to the move up / down hotkeys for consistency sake, and so you don't have to constantly adjust modifiers while you are moving tree items around. So I would recommend that either all of them should be ctrl+shift+arrow or ctrl+arrow (the former seems better, so that people used to novelWriter using ctrl+shift to move up+down don't have to relearn).

The Shift part of those shortcuts have been dropped in version 1.2 Beta 1, so they will all have the same modifiers.

Global key shortcuts for move tree item?

Is there any way to make the 'tree movement' keyboard shortcuts accessible from the document editor and all other focused panes? This would likely require different shortcuts to ctrl+shift+arrow or ctrl+arrow, since those are used in the text-editor. It could perhaps use vim-style keys, like ctrl+shift+j/k/h/l, to move the currently selected tree item down/up/left/right.

The advantage to that approach would be that it would make the restructuring or moving around of sections even faster, without requiring changing the focus with alt+1 first, and then moving the focus back to the editor with alt+2.

Making changes to the tree while in the editor has mostly been blocked because several users have pointed out that this is unexpected. I'm inclined to agree. People press keys that unexpectedly make changes elsewhere and don't always notice it. I could add some finger-cracking complex shortcuts, but do you really move files around that often?

Shortcuts to move items in outline mode?

I imagine this would require more significant re-architecting, but it would be incredible if eventually items in the outline mode could also be moved up, down (in the hierarchy) and 'left' and 'right' (which in novel mode, could change the header level of a section). This would also have to move all 'child' content (including child headers and normal text) around the hierarchy.

Again, I'm not sure if the current code base is conducive to it, but it would make the outline view significantly more useful (much like outline mode in Microsoft Word, for instance).

I see the appeal here, but this has been suggested before and will not be implemented. Moving sections in the Outline would imply modifying the user's files by switching order of headings or moving content from file to file automatically. I'm reluctant to add features that modify files that aren't currently open in the editor. This is one of the reasons the editor is so robust when it comes to keeping the core text files safe.

It is also somewhat redundant because if you split up the novel into scene files, you can already do this in the project tree. This is in fact one of the main reasons I made novelWriter in the first place. :)

protostork commented 3 years ago

Awesome, thank you for considering and explaining, all of those are good points and are very reasonable.

Also, yes, I have to admit I probably use far more finger cracking shortcuts than normal :smiley:

protostork commented 3 years ago

Was just looking through the repo some more and wanted to let you know what an incredible project this is with a really lovely codebase. I think you surpassed the mission you set yourself and then some! Thank you for writing it, I will be transitioning my projects from Scrivener (which I love but unfortunately does not work very well on Linux - and in many ways novelWriter is actually better).

Another tiny observation related to the above discussion, if I may: I understand your point regarding preventing moving tree items from within the document editor. That said, the current UI may be a little counter-intuitive for new users: if selecting move item down / up from the Tools menu (while in a document view), nothing happens and there's no real indication that the user has to move the focus to the project tree first.

It would make more sense if the "Tools" menu option was either:

If you think any of the above seem useful, I would be happy to try to implement something and submit a pull request (though my code would likely be far less efficient and elegant than it currently is :)

vkbo commented 3 years ago

These are all good suggestions. I'm in the process of cleaning up a bit how these things work. In particular with regards to which widgets have focus and what shortcuts do when certain widgets are active. Some improvements have been made for the next 1.2 release, currently in testing, and I'll take your suggestions into account when I get back to this on the 1.3 release track, currently in dev.

What's already been changed is moving the two menu entries from the Tools menu to the Project menu, which puts them in a context with actions that only act on the project tree. In addition, I've made the shortcuts a bit simpler. They've also been added to the context menu recently in 1.1, and could potentially be removed from the main menu.

tmarplatt commented 1 year ago

I suppose this would work:

* `Ctrl+Left` will move the item out of its folder, unless it's already in a root folder.

* `Ctrl+Right` will move the item into the next folder below its current location, if one exists.

About the latter, I would like to suggest that the item is moved into the folder above instead of below, as moving items is something that commonly happens for newly created items, which are spawned at the bottom of the current select tree level.

vkbo commented 1 year ago

I'm considering removing the entire feature of moving items in the tree like this with arrow keys. It is a source of mistakes, and the change isn't necessarily very noticeable when not deliberate, but fundamentally changes the flow of your text. I have never been happy with this feature.

I think an implementation of Ctrl+X, Ctrl+C and Ctrl+V in the tree would make more sense. It is what most file managers do, so people expect it, and it isn't as prone to mistakes. Especially as long as the cut is not processed until there is an active paste event.

This will allow for more freedom in moving items, with pretty standard UI functionality, and solves multiple features in one go.