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

后端 未结 10 1263
一向
一向 2020-12-02 03:34

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:

相关标签:
10条回答
  • 2020-12-02 03:42

    It's mentioned by @watsonic that in Sublime Text 3 on Mac OS, starting with an empty selection, simply G (AltF3 on Windows) does the trick, instead of D + G in Sublime Text 2.

    0 讨论(0)
  • 2020-12-02 03:43
    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.

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

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

    More commands:

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

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

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

    Sublime Docs

    0 讨论(0)
  • 2020-12-02 03:45

    The Magic is, you have to start with an empty selection, so put your cursor in front of the word/character you want to multi-select and press Ctrl+D .

    0 讨论(0)
  • 2020-12-02 03:45

    As user1767754 said, the key here is to not make any selection initially.

    Just place the cursor inside the variable name, don't double click to select it. For single character variables, place the cursor at the front or end of the variable to not make any selection initially.

    Now keep hitting Cmd+D for next variable selection or Ctrl+Cmd+G for selecting all variables at once. It will magically select only the variables.

    0 讨论(0)
  • 2020-12-02 03:47

    At this moment, 2020-10-17, if you select a text element and hit CTRL+SHIFT+ALT+M it will highlight every instance within the code chunk.

    0 讨论(0)
  • 2020-12-02 03:48

    I know the question is about Macs, but I got here searching the answer for Ubuntu, so I guess my answer could be useful to someone.

    Easy way to do it: AltF3.

    0 讨论(0)
提交回复
热议问题