When editing a file in Atom Editor how do I select multiple lines where the same edit needs to be performed?
For example:
this.name = name;
this.age = age;
this.sound = sound;
needs to be transformed into:
that.name = name;
that.age = age;
that.sound = sound;
Imagine there are many of these lines, but we do not want to use a find-and-replace because it will change more than we need.
Is there a sequence of keyboard shortcuts (preferably Mac) which we can use to:
then apply the change to several lines at once (in bulk)
I know how to do this in SublimeText: http://sublime-text-unofficial-documentation.readthedocs.org/en/latest/editing/editing.html#column-selection but have tried many different key combinations without any luck in Atom and googling has proved fruitless...
Alt+E – Open Edit menu. Alt+V – Open View menu.
Hold the modifier key then click and drag with the configured mouse button across multiple lines. Dragging vertically places carets on each line at that column; dragging horizontally as well selects the text on each line.
Editing a file is pretty straightforward. You can click around and scroll with your mouse and type to change the content. There is no special editing mode or key commands. If you prefer editors with modes or more complex key commands, you should take a look at the Atom package list.
There are several ways to achieve this:
You can enable column selection mode using Ctrl+Shift+↑/↓. This will allow you to extend the cursor to multiple rows. Once you have selected all rows, release the keys, and use the Delete key to remove the text you want to replace. Once you're done, press the Esc key to release the cursors.
Note: You will have to disable the Mission Control (key bindings) in OS X to use this key combo.
To do this open System Preferences > Mission Control
Locate the key bindings for Mission Control and Applications windows:
Disable the key bindings for these two:
More details here.
If you install the Sublime Style Column Selection package, you can use Alt+Mouse to select the columns in question.
More details here.
Here is a plugin for Atom, just hold alt and be happy. sublime-style-column-selection
With the cursor somewhere on the first "this", do Ctrl+D (OS X: command+D) three times. Then type "that".
Another option is to select the rows you want to edit. Then select "Split into Lines" from the "selection" menu. Then hit the home-key and start editing away in multi-cursor mode.
For me on Atom 1.7.4 it worked by adding below lines to my /Users/username/.atom/keymap.cson. Ofcourse I am using alt-shift-down as shortcuts.
'atom-workspace atom-text-editor:not([mini])':
'alt-shift-down': 'editor:add-selection-below'
Update: I could not configure both alt+shift+down and alt+shift+up at the same time. For now I am okay with alt+shift+down
On Windows 10, follow the following steps:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With