Does Atom supports region operation?


#1

Sometimes, I only want the operation affects the selected region. Is there any package makes this possible?

This post says that “vim allows you to select a region and operate on it” while the name of the post is “Why Atom Can’t Replace Vim”.


#2

Are you asking about Atom specifically or the vim-mode and vim-mode-plus packages?


#3

Atom specifically


#4

You’ll need to be more specific about what you mean by regions. The post you linked does not provide details about this feature.


#5

If what you want is column (or rectangular) selection, you can do this in Atom.
The shortcut changes with systems, I think. It seems it is done with Ctrl+Shift+up/down arrows on Macs, and Ctrl+Alt+up/down on my Windows.
This extends the selection toward the top or the bottom, so you get an extended caret.
You can then use backspace, delete, type, shift+left/right arrows to extend the selection horizontally, etc.
Side note: I find the choice to extend in both direction not useful (in general, we start from one end) and annoying, because if we overshot (go one line more than wanted), the opposite direction key doesn’t reduce the selection, but extend it in the other direction, which worsen the problem and forces to redo it…

If you prefer the mouse, there is the https://atom.io/packages/Sublime-Style-Column-Selection package which allows to do a column selection with Alt+drag.

Atom also supports multiple carets with Ctrl+click at the wanted places. Ctrl+click on one of these carets removes it, too.

If that’s not what you mean by regions, you have to tell us more…


#6

The feature of region operation is that

  1. I select some texts and press some key combination to start the region operation;
  2. I do any possible operations, but they only affect on the selected texts;
  3. I finish the region operation and quit this mode by pressing some key combination;

A simple implementation of this feature is just open a blank file by side, copy the selected texts to the blank file and then do operations on this file, at last copy and paste back.


#7

What operations are you performing? Atom does have a few methods that only affect selected text, and it would definitely be possible to break the selection out into a temporary TextBuffer or a modal panel and then reintegrate it when the quit command is called.


#8

“any possible operations” as we can do on the normal text. It’s a good idea [quote=“DamnedScholar, post:7, topic:36296”]
to break the selection out into a temporary TextBuffer or a modal panel and then reintegrate it when the quit command is called.
[/quote]

I’m looking forward a package to do this.


#9

If you have specific desires, then there might be features that exist already, like how the Find and Replace function has a toggle to only work within selected text.


#10

Could you show me how?

But the method “temporary TextBuffer or a modal panel” is still a better and unified solution.


#11

It’s one of the toggle buttons on the right side of the top row. You can mouse over them to check their tooltips.