How do I replace text in a selection?

2019-03-07 12:48发布

I've just started using Sublime Text 2, coming from emacs.

I have a region of text selected. Within that region, I'd like to replace all text instances of '0' with '255'.

How do I do this kind of text replacement?

11条回答
啃猪蹄的小仙女
2楼-- · 2019-03-07 13:27

You can use ctrl+F to find the text.
ctrl+h to enter the replacement text. Then ctrl+shift+h to replace the current selected text and move to next matched text.

This is for windows. But you can check in mac also for which you might want to check the key bindings under Preferences.

查看更多
地球回转人心会变
3楼-- · 2019-03-07 13:27

As @JOPLOmacedo stated, ctrl + F is what you need, but if you can't use that shortcut you can check in menu:

  • Find -> Find..

    and there you have it.
    You can also set a custom keybind for Find going in:

  • Preferences -> Key Bindings - User

    As your request for the selection only request, there is a button right next to the search field where you can opt-in for "in selection".

  • 查看更多
    唯我独甜
    4楼-- · 2019-03-07 13:28

    1) Ctrl + F (or Cmd + F on a Mac);
    2) Enter the string you want to find on the input at the bottom of the window.
    3) Press "Find All";

    All of the appearances are now selected. Do whatever you want.

    Aside

    There are a bunch of options at the left of the input that opens on Ctrl + F. There's one that says something like "Find in selected text". Select a bunch of text, check that option and repeat the same steps above starting from 2). Now, only matches belonging to that selection are selected.

    查看更多
    不美不萌又怎样
    5楼-- · 2019-03-07 13:35
    1. Select the item you want to replace (double-click it, or Ctrl - F to find it)...

    2. Then do a (Ctrl - Apple - G) on Mac (aka. "Quick Find All"), to HIGHLIGHT all occurrences of the string at once.

    3. Now just TYPE your replacement text directly... All selection occurrences will be replaced as you type (as if your cursor was in multiple places at once!)

    Very handy...

    查看更多
    \"骚年 ilove
    6楼-- · 2019-03-07 13:37

    On a Mac you can can select the text that you are after then press: cmd + ctrl + G

    This will select every instance of your selected text within the same document. If you now start typing to replace your original highlighted text, you will replace all of the other occurrences at the same time.

    查看更多
    登录 后发表回答