Sublime Forum

Ctrl+Shift+D replaces wrong variable

#1

I wanna rename a variable in code so i marked it
[first half of the image]
and it highlighted it, while excluding the variables that have the same name plus an additive.
Perfect as expected.

When i then try to only rewrite this variables instances by pressing Ctrl + Shift + D
it marks all instances of this String, aka also the other similarly named variables.
[second half]
sbl%20hate%20you
Bad subl.

I thought there may be a key binding that i didn’t knew about that could do this correctly,
The other keybindings that i found to be close are these

{ "keys": ["ctrl+d"], "command": "find_under_expand" },  // which does it wrong
{ "keys": ["ctrl+k", "ctrl+d"], "command": "find_under_expand_skip" }, // ctrl+k doesn't do anything

// these all just navigate trough the found String
{ "keys": ["f3"], "command": "find_next" },
{ "keys": ["shift+f3"], "command": "find_prev" },
{ "keys": ["ctrl+f3"], "command": "find_under" },
{ "keys": ["ctrl+shift+f3"], "command": "find_under_prev" },

{ "keys": ["ctrl+shift+d"], "command": "duplicate_line" }, // :I

Anyone knows how i can select&rename/replace only this one variable?
ps: had to combine both images to one as new users ar prohibited to post two images in a post.
whoever idea that was…

0 Likes

#2

You have the answer in your question itself. Whenever something doesn’t match acc exactly, use ctrl+k, ctrl+d to skip it & go to the next instance.

I believe those who join the forum for the first time are allowed only one image per post (If I am not misremembering)

0 Likes

#3

If text is selected all tokens which match the selection are marked by ctrl+d without respecting any word boundaries.

You should just place caret onto acc and hit ctrl+d.

1 Like

#4

Yeah no,
Ctrl+D will select the next found instance of the selected Text,
Ctrl+K (when pressed double) deletes the current line
Ctrl+Shift+D marks all instances of the String with no respect to similar variables
Ctrl+Shift+K deletes the current line

Yes that’s exactly what i’ve told already and that it’s annoying.

0 Likes

#5

when replacing strings with Ctrl+Shift+D, inserting a caret(^)will overwrite the currently selected string.
Only in Replace Windwow that’ll work

0 Likes

#6

Don’t select anything. Just place the caret onto acc and hit ctrl+d to select all other instances.

1 Like

#7

There is a misunderstanding of the word caret.
I didn’t knew what is meant and
startpage sayd it’s this en.wikipedia.org/wiki/Caret
aka[^] aka 0x5E aka U+005E

What you meant is the text cursor.
and since it works as a regex in ctrl+H replace mode, i thought that’s what you meant.

anyway. yea that does work but it doesn’t select all matches and you’ve to manually go trough each and single one of em,
Exactly what Ctrl+Shift+D tries to solve but it ,as said, doesn’ tpay any respect to the word boundaries

0 Likes

#8

Yes, ctrl+d selects only one instance (hitting ctrl+k, ctrl+d in sequence skips current selection).

ctrl+shift+d simply duplicates a line (or selected text) for me. If something else happens for you, a plugin might be causing it. It would then be the one to blame for wrong selections, maybe?

0 Likes

#9

Also note that the default way to select all instances is alt+f3 or ctrl+cmd+g.

1 Like