typora / typora-issues

Bugs, suggestions or free discussions about the minimal markdown editor — Typora
https://typora.io
1.53k stars 56 forks source link

Feature Request: Custom ordering of files and folders in Files sidebar #3655

Open rezanid opened 4 years ago

rezanid commented 4 years ago

When the number of files and folder structure grows over time, the default alphabetic ordering of files and folders in the Files sidebar is not enough. Some times a different order would be more suitable. For example the order that content needs to be read. Although this can be done by prefixing file and folder names with numbers, but doing that would hinder readability.

I have seen some other tools that have an interesting approach to address this issue. In AzureDevOps for example, files and folders are sorted alphabetically by default, but if it finds a file with the name ".order" in any folder (including the root), it will first display the items listed in that file. You can use this technique to customize the ordering of files and sub-folders under any folder.

Example: Imagine you have a folder that contains some files and folders like the following.

+ Getting Started
+ Resiliency
+ Security
- Data Synchronization.md
- Resiliency.md
- Welcome.md

If you add a ".order" file with the following content

Welcome

The structure will be displayed like so:

- Welcome.md
+ How to get started
+ Resiliency
+ Security
- Data Synchronization.md
- Resiliency.md

It means that all the files (and folders) mentioned in the ".order" file are listed first and then whatever that is not mentioned in the ".order" file would come after in alphabetic order. To show another example, given the following ".order" file:

Welcome
Resiliency

Would result to showing the structure like so:

- Welcome.md
- Resiliency.md
+ How to get started
+ Resiliency
+ Security
- Data Synchronization.md

Ideally users should be able to change the display order by dragging files or folders up / down and the result would be reflected in the .order file.

angshumand commented 4 years ago

Yes, this would be invaluable.

hollispotter commented 3 years ago

I would also find this invaluable. I currently have a text file that just has a list of paths in the correct order, not unlike the .order file above, that my own script uses to compile chunks into the final doc. I use Typora as my preferred notes app, and have found no tool that performs as well. Even if the sort could use an external command, that would be plenty good enough for me, and would not introduce feature creep. Having the order accessible outside of Typora would be important.

1999FordFocus commented 2 years ago

+1

skythomp16 commented 2 years ago

I would also love to use this. I am currently using Typora as a massive digital tabbed notebook and would love to be able to sort the sections (folders) in what order I want.

willzhang commented 7 months ago

It's really painful without sorting,If I have 10 documents in each subdirectory, it's completely chaotic.

image

Is it feasible to use SUMMARY.md as a sidebar? Use SUMMARY.md to link files.

* [1](1.md)
* [2](basic/2.md)
    * [introduction1](basic/2.2.md)
    * [introduction2](basic/2.3.md)
Matheus-de-Mello-Vieira commented 7 months ago

You can use numerical prefix to order your files

You need to include left 0 in order to alphabetical ordering be the numerical ordering.

image

willzhang commented 7 months ago

If you want to reorder later, or delete or insert one of the files, you will receive a surprise---rename all of them.

Matheus-de-Mello-Vieira commented 7 months ago

If you want to reorder later, or delete or insert one of the files, you will receive a surprise---rename all of them.

You can use a Python, or any other programming language to solve it, for example:

from pathlib import Path
import re

FILE_NAME_PATTERN = re.compile(r"(0*\d+) .*")

target_folder = Path(input("Target folder:"))
intervention_begin = int(input("Intervention begin:"))
intervention_end = int(input("Intervention end:"))
increment = int(input("Increment:"))

for target_file in target_folder.iterdir():   
    regex_groups = FILE_NAME_PATTERN.findall(target_file.name)

    if regex_groups:
        str_old_number = regex_groups[0]

        old_number = int(str_old_number)
        if intervention_begin <= old_number and intervention_end >= old_number:
            new_number = old_number + increment

            str_new_number = str(new_number).zfill(len(str_old_number))

            target_file.rename(target_folder / target_file.name.replace(str_old_number, str_new_number, 1))

This will rename the target_folder' files from intervention_begin to intervention_end (inclusive) by adding increment (that can be negative).

mzbrau commented 5 months ago

Docusaurus uses front matter to order the documents which is a small YAML section at the top of the markdown file. By specifying a sidebar_position property, items are ordered accordingly. (See here). This would be a really nice addition, especially when working with documents that will also be presented in Docusaurus.

e.g.

---
sidebar_position: 1
---

# Introduction
Introduction section of document.
samwyzz commented 2 months ago

+1 Custom Ordering of files/folders is such a critical feature.

Users should be allowed to drag and drop files/folders to reorder them, with the order being persisted within the application. Would be really great if such a feature was added to Typora.

Sadly this is a limitation found in most markdown note taking apps, one that greatly hinders the note taking experience.

Relying on alphabetical order for organizing notes does not seem logical or intuitive, as note taking is rarely a linear process. Note taking is a fluid process which requires structuring and ordering files constantly.

Manually prefixing files/folders with numbers to achieve a specific order is not a viable long term solution. Adjusting the order of even one file requires renaming all others, which becomes impractical when managing a large number of notes.