question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Request: Shortcut to reorder list item

See original GitHub issue

Expected Behavior

When moving a list item, I would like to be able to move an item in a (vertical) list up or down without manually shuffling commas and brackets, and knowing where the actual ending comma for this line item is. This could/should also be applied to horizontal lists if this is possible.

Current Behavior

[ "Pear"
, "Apple"
, "Orange"
]

If I want to move paragraph Apple below Orange I can press Alt-Down with the cursor and the lines will shuffle, and no manual changes needed.

BUT If I want to swap Pear and Apple, i can swap these using Alt-Up/Down. But I then need to replace the initial [ of Pear with a leading , comma, and replace the leading comma from Apple with a starting bracket.

This is even more a feature that would be great if it would support multiple line content in lists.

[ paragraph
                [ Font.bold
                , Font.underline
                ]
                [ text "My local fruit collection" ]
, paragraph [] [ text "My fruit company salespitch" ]
]

If I could have my caret on the "paragraph on line 1, and press a key to move it and all implementation down in the list without having to select, move, replace commas and brackets and all that churn work, this would be a fantastic feature in my mind.

[ "Pear", "Apple", "Orange"]

I would also like to be able to move items in such lists with the same shortcut (but it is not a priority). If I have my caret on Orange and press the shortcut I would swap Apple and Orange.

Context

Since elm language clients has access to the syntax tree I believe this could be added, but I have no idea how. This feature might actually already exist, but I have not found it. If it does I would be happy to know 😃

Is this an interesting proposal, and is it something that could be contributed if so? And is this a question for the vscode addon or the Elm-LanguageServer?

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
razzeeecommented, Feb 28, 2021

I think sending a WIP merge request would be the best way to move forward 😃

1reaction
Streptocommented, Feb 27, 2021

moveactions

I took a shot at how this could be implemented 😄

There are some issues I’m aware of though:

How to handle comments:

Example elm-format formatted code

rangeSlider
            -- General List Comment?
            [ -- First item comment
              Html.Attributes.max "11"

            -- Is this commenting the next item?
            , -- Or is this the comment for the next listitem
              onSlide toMsg
            , Html.Attributes.property "val" (Json.Encode.int magnitude)
            ]

I think this should move the comments as well if there are any, and this would be easy if the comments were placed within the same list item. But not sure how to handle comments on last line before next list item.

Cursor

The cursor does not follow along, and this makes adding smooth keyboard shortcuts less possible. Not sure if there are any fixes for this. I would have liked to add “Ctrl-Alt-Shift-Up” as a move the current item up in the list, with possibility for repeated keypresses. But I’m not sure if that is possible if the cursor does not follow along.

Currrently all code is within a CodeAction in the Language Server, so it is VSCode independent. I’m not proficient in TypeScript, and hacked this together. If its interesting to add I can try refactoring to something testable.

https://github.com/Strepto/elm-language-server/tree/swaplistitems-codeaction

Read more comments on GitHub >

github_iconTop Results From Across the Web

Reorder shortcuts on iPhone or iPad - Apple Support
You can reorder shortcuts in the Shortcuts app. ... In the Shortcuts app on your iOS or iPadOS device, tap Edit. Drag one...
Read more >
How can I create a shortcut to easily reorder an item?
For a single item, search for the item, select it, and click Add to Shopping List. To use the shortcut, select the item...
Read more >
Reorder List Items with Keyboard Shorcuts - Obsidian Forum
One of the features I really miss from Roam is the ability to move a list item “up” and “down” in the list...
Read more >
Keyboard shortcuts to reorder items in the tags panel ...
Keyboard shortcuts to reorder items in the tags panel (Accessibility Tool). Please add keyboard shortcuts to reorder items in the tag panel.
Read more >
Word How-To: Easily Reorder Items in a List (Shortcut Trick)
It's so easy - how to use a key combination to change the order of items within a list. Applies when working in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found