Atom editor - multiselect by line

7.6k views Asked by At

I am moving from Sublime to Atom, and can't find a certain hotkey for the life of me.

Control+D will still do a multi-select - select the next instance your highlighted text, at which point you will get multiple cursors.

In Sublime, if you selected multiple lines and pressed control+shift+l, it would then create a cursor on each line, so you could edit each line at once.

I looked through the hotkey lists for Atom, and can't find this. But then I probably don't know the right terminology.

5

There are 5 answers

0
user12341234 On

I recently apm'd this package, though I'm not sure if there's a hotkey: https://atom.io/packages/sublime-style-column-selection

0
Pau Coma Ramirez On

Adding Key-Binding to Selection --> Split into Lines

To add the ctrl+shift+L Key-binding to this you need to edit your custom keymap file.

  1. Edit --> Keymap... :opens keymap.cson file
  2. You can use ctrl+. to open a Key Binding Resolver to view currently assigned Key-Bindings to check if the desired key-binding is already occupied.
  3. To re-map a currently occupied binding simply redifine it in the custom keymap file.
  • in my case grammar-selector:show needed remapping, (remapping to ctrl-shift-j in this case)

Append to : keymap.cson

  ".platform-darwin atom-text-editor":
    "ctrl-shift-j": "grammar-selector:show"
  ".platform-win32 atom-text-editor":
    "ctrl-shift-j": "grammar-selector:show"
  ".platform-linux atom-text-editor":
    "ctrl-shift-j": "grammar-selector:show"
  1. Now we add the desired keybinding (as defined in the multi-cursor package description)

Append to : keymap.cson

  '.platform-darwin atom-text-editor:not([mini])':
    'ctrl-shift-l': 'editor:split-selections-into-lines'
  '.platform-win32 atom-text-editor:not([mini])': 
    'ctrl-shift-l': 'editor:split-selections-into-lines'
  '.platform-linux atom-text-editor:not([mini])':
    'ctrl-shift-l': 'editor:split-selections-into-lines'
  1. Save keymap.cson and Restart Atom.

Note: I have only tested this on linux. Note2: on mac , i.e. darwin this may not be needed

2
Pankil Shah On

For Windows users,
the default keybindings ctrl + shift + up / down seems to work.

For Mac users,
add the following custom keybinding code to the
/user/<yourName>/.atom/keymap.cson file

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# change the keybinding for ADD SELECTION ABOVE / BELOW
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#  'shift-alt-up': 'editor:add-selection-above'
#  'shift-alt-down': 'editor:add-selection`-below'
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Then place the cursor where you want to start and press and hold shift + alt and press up or down repeatedly to extend the cursor to as many lines as needed.

1
Shiv Kumar Baghel On

Use the multi-cursor package.

Use CTRL/COMMAND to select multiple places.

0
George C On

The command in the menu Selection —> Split into Lines should do what you want. On the Mac the keyboard shortcut is cmd-shift-l.