Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

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

keyboard shortcuts - How to select all instances of a variable and edit variable name in Sublime

If I select a variable (not just any string) in my code, all other instances of that variable get a stroke (white outline) around them:

enter image description here

Is there a keyboard shortcut that will let me select all of those instances of the variable and edit them all at once?


Things I've Tried:

?D, ?K, and ?U lets me select them one-by-one, but I have to manually exclude the non-variable string matches:

enter image description here

And using Ctrl?G simply selects all the string matches:

enter image description here

Clearly, Sublime is able to differentiate between variable and string matches. Is there no way to select just the variable matches?

See Question&Answers more detail:os

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

1 Answer

0 votes
by (71.8m points)
  1. Put the cursor in the variable.

    Note: the key is to start with an empty selection. Don't highlight; just put your cursor there.

text cursor on variable

  1. Press ?D as needed. Not on a Mac? Use CtrlD.

more instances of variable highlighted

Didn't work? Try again, making sure to start with nothing selected.

More commands:

Find All: Ctrl?G selects all occurences at once. Not on a Mac? AltF3

Undo Selection: ?U steps backwards. Not on a Mac? CtrlU

Quick Skip Next: ?K?D skips the next occurence. Not on a Mac? CtrlKCtrlD

Sublime Docs


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...