Skip to content
This repository was archived by the owner on Mar 3, 2023. It is now read-only.

Add commands to move selections left and right by one column - #6631

Merged
mnquintana merged 17 commits into
masterfrom
mq-move-selected-columns
Mar 31, 2016
Merged

mnquintana merged 17 commits into
masterfrom
mq-move-selected-columns

Conversation

@mnquintana

Copy link
Copy Markdown
Contributor

See https://discuss.atom.io/t/shift-selection-by-column/16545?u=mnquintana for more background

screencap1

This adds the column-equivalent of TextEditor::moveLineUp() and TextEditor::moveLineDown() - instead of moving a line up or down, these commands move any active selections left or right by one column. This is especially useful if you're refactoring / generally trying to clean up your code.

TODO:

  • Add keybindings for Linux and Windows (anyone have any suggestions for good keybindings for this?)
  • Consider renaming commands? (Is Move Selection Left / Right too vague?)
  • Fix case when moving multiple one-line selections to either the beginning or end of the line

Shoutout to @lee-dohm for helping with the implementation 👋

/cc @atom/feedback

@YurySolovyov

Copy link
Copy Markdown

Add keybindings for Linux and Windows (anyone have any suggestions for good keybindings for this?)

Not sure about Windows, but Alt + (Left) Shift + Left | Right Arrows seem to do nothing on Ubuntu ATM

@thomasjo

thomasjo commented May 4, 2015

Copy link
Copy Markdown
Contributor

Not sure about Windows, but Alt + (Left) Shift + Left | Right Arrows seem to do nothing on Ubuntu ATM

If you read the TODO list, you'll see this

Add keybindings for Linux and Windows (anyone have any suggestions for good keybindings for this?)

🙈

@YurySolovyov

Copy link
Copy Markdown

@thomasjo I was just suggesting these keys. "seem to do nothing" -> can be taken for this PR's functionality.

@thomasjo

thomasjo commented May 4, 2015

Copy link
Copy Markdown
Contributor

@YuriSolovyov Aaah, I misunderstood what you were saying; so you were suggesting those as possible keybinds. Sorry about the confusion! And yeah, those seems like sensible suggestions 👍

@lee-dohm

lee-dohm commented May 4, 2015

Copy link
Copy Markdown
Contributor

Things look good to me! 👍

@benogle benogle added the atom label May 4, 2015
@mnquintana
mnquintana force-pushed the mq-move-selected-columns branch from 1b98d60 to de186c1 Compare June 18, 2015 11:15
@benogle benogle added atom and removed atom labels Jan 26, 2016
Comment thread src/text-editor.coffee Outdated
translatedRanges = []

@transact =>
if noSelectionAtStartOfLine

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make more sense for this conditional to encompass the transaction too?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think if the transaction is a no-op when the selection is at the start/end of line, then we shouldn't create the transaction.

@mnquintana

Copy link
Copy Markdown
Contributor Author

This should be ready for review again! (I'm happy I managed to get back to this one just under the year mark... 😅)

Right now I'm debating switching this over to screen ranges to keep behavior consistent if soft wrap's enabled, but I'm not sure right now which would be more intuitive. 💭s?

Otherwise, @atom/feedback plz try this out and let me know if you catch anything weird! 🙇

@lee-dohm

Copy link
Copy Markdown
Contributor

In testing it out, I'm getting the same error beep behavior that we've seen when using Cmd+Ctrl+Down for each left/right movement on OS X. I don't think that's an issue with the PR, just something I noticed. Also, it appears that Cmd+Ctrl+Up/Down move the entire line, rather than just the selection. Again, not something specifically to block this, but to be aware of.

@mnquintana

Copy link
Copy Markdown
Contributor Author

In testing it out, I'm getting the same error beep behavior that we've seen when using Cmd+Ctrl+Down for each left/right movement on OS X.

Yup 😞 that one's blocked on electron/electron#2617 right now.

Also, it appears that Cmd+Ctrl+Up/Down move the entire line, rather than just the selection. Again, not something specifically to block this, but to be aware of.

That's true – that was something I considered early on with this. Like, the literal counterpart of Move Line Up / Down would be to shift an entire column left or right (since the former is just shifting an entire row up or down), but that wouldn't be very useful. This is more the functional counterpart to Move Line Up / Down.

🚢?

@lee-dohm

Copy link
Copy Markdown
Contributor

👍 I think this is good to go, yep 🚀

@mnquintana
mnquintana merged commit 36be446 into master Mar 31, 2016
@mnquintana
mnquintana deleted the mq-move-selected-columns branch March 31, 2016 05:30
@paride

paride commented May 30, 2016

Copy link
Copy Markdown

It seems to me that on Linux alt+shift+(left|right) conflict with these keybindings:

    "alt-shift-left": "editor:select-to-previous-subword-boundary",
    "alt-shift-right": "editor:select-to-next-subword-boundary",

See linux.json:99 and :100.

@marat93

marat93 commented Jun 7, 2016

Copy link
Copy Markdown

same for me. alt-shift-right just selects next word. Ubuntu 14.04, atom 1.8.0

@davesmiths

Copy link
Copy Markdown

Thank you so much for this, love it!
on OSX CMD+CTRL+LEFT/RIGHT

@AlexWayfer

AlexWayfer commented Jun 7, 2016 •

Copy link
Copy Markdown

image
Looks like too many key-bindings, and works in fact only one (not clear which)
Arch Linux, Atom 1.8.0

@mnquintana

Copy link
Copy Markdown
Contributor Author

Ah well that's a bummer – that's what happens when you merge a PR 1 year later I guess 😞 (this definitely didn't conflict at the time!)

I'll look into a new keybinding for this. Thanks everyone for bringing it to my attention! 😄

@Dayjo

Dayjo commented Jun 7, 2016

Copy link
Copy Markdown

It was but 2 weeks ago when I thought to myself "I wish I could move selections left and right as well as up and down".. and today this!

Good luck getting the binding sorted, and thanks! :)

@ghost

ghost commented Jun 10, 2016 •

Copy link
Copy Markdown

I was disappointed to find that the default key bindings for move-selection-left and move-selection-right don't work in Linuxmint 17.3 Cinnamon 64 bit on my MSI laptop. I was able to get them working with the windows-alt-left and windows-alt-right key combos by putting the following in my keymap file, keymap.cson:

'atom-text-editor':
    'cmd-alt-left': 'editor:move-selection-left'
    'cmd-alt-right': 'editor:move-selection-right'

So does anyone know if atom will always recognize the Linux super key when you define a key binding with 'cmd?' On Windows boxes super is the Windows key, but what about on PCs built to run Linux like those from System76, zareason, Entroware, etc?

@impankratov

impankratov commented Jul 20, 2016 •

Copy link
Copy Markdown

Rigth now on windows i'm using:

'atom-text-editor':
  'ctrl-alt-pageup': 'editor:move-selection-left'
  'ctrl-alt-pagedown': 'editor:move-selection-right'

maybe those are not the most intuitive, but they work and don't conflict with anthing.

By the way, @Not-A-Hacker cmd-alt-* combinations don't work on windows.

@ForeverWinter

ForeverWinter commented Feb 1, 2017 •

Copy link
Copy Markdown

For shortcuts: What about Ctrl+< and Ctrl+> (i.e. ctrl+shift+, and ctrl+shift+.)

@AlexWayfer

Copy link
Copy Markdown

@ForeverWinter So we need to replace exist shortcut:

image

@ForeverWinter

Copy link
Copy Markdown

Ah yes, I missed that. Could make "scroll-to-cursor" ctrl-? (ctrl-shift-/). Alternatively, could make the shift left and right Alt-< and Alt-> (alt-shift-, and alt-shift-.) instead.

@AlexWayfer

Copy link
Copy Markdown

Alt-> is occupied.

image

@ForeverWinter

Copy link
Copy Markdown

Alt-> is occupied.

alt-> linter:next-error

Yeah, but not by any core packages. Granted, Linter is one of the most common community packages; it should probably be taken under consideration given its popularity, but I didn't have it installed when checking for shortcut conflicts.

@ZdrytchX

ZdrytchX commented Aug 31, 2017 •

Copy link
Copy Markdown

Grouping Does not work well with python because python does not have brackets 😢

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.