zed icon indicating copy to clipboard operation
zed copied to clipboard

Add a function for sorting.

Open ZeroDot1 opened this issue 4 months ago • 6 comments

Check for existing issues

  • [X] Completed

Describe the feature

I think it is important to have a function for sorting lines. In most editors, this always has to be added on somehow. i think it is better to implement a sorting function directly. The sorting function should do the following. Sort the rows by number from A-Z and remove duplicates.

Such a function makes it easier for developers of e.g. blacklists for adblockers and other lists to quickly edit and exclude duplicates.

If applicable, add mockups / screenshots to help present your vision of the feature

No response

ZeroDot1 avatar Mar 01 '24 18:03 ZeroDot1

Addition, it should be possible to set that the function can be activated with the right-click menu.

ZeroDot1 avatar Mar 01 '24 18:03 ZeroDot1

Can you please give me an example of what you're talking about? I'm not sure what functionality you're referring to.

Moshyfawn avatar Mar 01 '24 18:03 Moshyfawn

Can you please give me an example of what you're talking about? I'm not sure what functionality you're referring to.

For example, you have a file in which the lines are not sorted by number and alphabetically. Example:

aaaaaaaa
99999999
xxxxxxxxx
bbbbbbbb
ffffffffffffff

And you need the file in a sorted form. For example, a file has 2500 entries that need to be sorted. Example:

99999999
aaaaaaaa
bbbbbbbb
ffffffffffffff
xxxxxxxxx

It is impossible to sort lines manually if a file has more than 100 entries, for example. Therefore I think a function for sorting lines should be implemented directly in the editor.

ZeroDot1 avatar Mar 01 '24 18:03 ZeroDot1

usually a function like the above is included within the language itself or a module if youre referring to a csv or something. are you referring to a csv file or the coding file within zed itself? if the zed file, im not sure what you mean, that could be

  1. automatic indentation
  2. corrected minor syntax (e.g. in python fixing errors between = == ===)
  3. automatically assigning proper name convention standards in a specific language like having zed rename all functions in gdscript to camelcase (if it had a language dictionary and broke the words down) and all class names to whatever name casing gdscript uses.
  4. correcting the spelling and grammar within strings (e.g. 'hlelo i am silly' to 'Hello, I am silly.')
  5. automatically assigning variable types and adding in automatic error catching like
    try:
        if f(x):  
            # f(x) is not None and not throw any exception. Your last case
            return "Generic"
        # f(x) is `None`
        return "No Problem"
    except ValueError:
        return 'Value'
    except TypeError:
        return 'Type'
    except E2OddException:
        return 'E2Odd'
  1. common code optimisations (e.g. changing out one sorting method for another)
  2. better coding readability e.g. preventing nested if statements by using ! in python
  3. deleting extra lines
  4. etc.

very confused about this issue ngl

RustoMCSpit avatar Mar 01 '24 20:03 RustoMCSpit

Simple, what I mean is a simple function to sort the content of e.g. txt files not more and not less. Easily accessible with one or two clicks via a right-click menu.

ZeroDot1 avatar Mar 01 '24 20:03 ZeroDot1

The sorting function should do the following. Sort the rows by number from A-Z and remove duplicates.

@ZeroDot1 There is a builtin sort command already. Select whatever lines you'd like to sort, open the command palette (cmd-shift-p), and search for :sort.

This is not going to remove duplicates. A separate command to remove duplicate lines might be interesting, but I would not expect a sort function to remove lines.

baldwindavid avatar Mar 02 '24 00:03 baldwindavid

As @baldwindavid mentions, we already have this functionality available:

  • The editor: sort lines case sensitive and editor: sort lines case insensitive commands will sort the selected lines
  • The editor: unique lines case sensitive and editor: unique lines case insensitive commands will sort the selected lines as well as remove any duplicates

maxdeviant avatar Mar 02 '24 01:03 maxdeviant

As @baldwindavid mentions, we already have this functionality available:

  • The editor: sort lines case sensitive and editor: sort lines case insensitive commands will sort the selected lines
  • The editor: unique lines case sensitive and editor: unique lines case insensitive commands will sort the selected lines as well as remove any duplicates

do you have the stuff i mentioned?

RustoMCSpit avatar Mar 02 '24 01:03 RustoMCSpit

As @baldwindavid mentions, we already have this functionality available:

  • The editor: sort lines case sensitive and editor: sort lines case insensitive commands will sort the selected lines
  • The editor: unique lines case sensitive and editor: unique lines case insensitive commands will sort the selected lines as well as remove any duplicates

do youve thr functionality i mentioned?

RustoMCSpit avatar Mar 02 '24 02:03 RustoMCSpit

@RustoMCSpit We'd appreciate it if you'd tone it down a bit. I've noticed that you've been spamming comments in a number of threads, some of which have been somewhat disrespectful, and now you're reposting your comment marked as off-topic. Let's keep it civil.

Moshyfawn avatar Mar 02 '24 02:03 Moshyfawn

Thank you very much, I will test it as soon as zed is available for #Linux.

ZeroDot1 avatar Mar 02 '24 10:03 ZeroDot1

@baldwindavid Hm, I was able to compile Zed so that it can be started under Linux, but how can I call the sorting function? I have found absolutely no way to do this.

ZeroDot1 avatar Mar 09 '24 20:03 ZeroDot1

@ZeroDot1 There is a builtin sort command already. Select whatever lines you'd like to sort, open the command palette (cmd-shift-p), and search for :sort.

@ZeroDot1 If it's not in the command palette then 🤷 . Perhaps someone on Linux can chime in.

baldwindavid avatar Mar 10 '24 21:03 baldwindavid

@baldwindavid Unfortunately, it is not even possible to access the command palette. I think there is still a lot of work to be done in the way of #Linux / #7015 . https://github.com/zed-industries/zed/issues/9155 https://github.com/zed-industries/zed/issues/8491

ZeroDot1 avatar Mar 11 '24 07:03 ZeroDot1