Sublime Forum

Replacing characters via the Ctrl+D method doesn't replace all instances

#1

Using the expand selection to word on this example doesn’t replace all instances of it.

See the gif below.

The commands I’m doing are:

  1. Ctrl + D
  2. BackSpace
  3. Then replace with ' character.

Jmy0sPLHmm

0 Likes

#2

When you press backspace on the two adjacent quotation marks, the two selections would result in the same location and ST joins them into a single one.

Instead, try this:

  1. Select "
  2. Press Alt+F3 (on non-macOS)
  3. Insert
  4. If auto_match is enabled, press Delete twice.
1 Like

#3

Thank you very much.

Should the expand to selection not behave the same way?

0 Likes

#4

As noted above, the issue that you’re seeing here is a result of two selections occupying the same space in the buffer; when that happens, Sublime merges them into a single selection. Both of the two quotes are properly selected, but once you delete them both cursors on that row end up on top of each other and get merged into one, so that when you start typing only a single item is inserted there.

Using Quick Find All (Alt+F3) is a shortcut for using Quick Add Next (Ctrl+D) enough times to select all of the instances; the thing that’s making the key sequence @FichteFoll posted above work is that it’s wrapping all of the selections in the quote character first, then removing the extra characters second so that the selections don’t overlap and merge.

0 Likes

#5

Yes, I should of thought of that too:

  1. Select "
  2. Press Ctrl+D (on non-macOS)
  3. Insert
  4. If auto_match is enabled, press Delete twice.
0 Likes