Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
438 views
in Technique[技术] by (71.8m points)

Is there a keyboard shortcut to select a column for editing in Atom editor?

Scenario

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.

Question - Is there a Keyboard Shortcut for Column Selection?

Is there a sequence of keyboard shortcuts (preferably Mac) which we can use to:

  • a) select the initial word
  • b) select the "column" (that word on several lines)

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...

question from:https://stackoverflow.com/questions/31652914/is-there-a-keyboard-shortcut-to-select-a-column-for-editing-in-atom-editor

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

There are several ways to achieve this:

Keyboard

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.

How to Disable Mission Control (conflicting) Key Bindings (Mac)

To do this open System Preferences > Mission Control

enter image description here

Locate the key bindings for Mission Control and Applications windows:

mission-control-key-bindings

Disable the key bindings for these two:

enter image description here

More details here.

Mouse

If you install the Sublime Style Column Selection package, you can use Alt+Mouse to select the columns in question.

More details here.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...