Find and replace in Visual Studio code

后端 未结 6 1819
不思量自难忘°
不思量自难忘° 2020-12-25 11:08

I have the following line in a file I\'m editing in VSCode:

...............111.........111.............111..

I want to replace all .

相关标签:
6条回答
  • 2020-12-25 11:21

    I was able to get it to work but the workflow is poor:

    1. control + H to open Find/Replace
    2. Select your line of text
    3. Click the "Find in selection" icon to the right Alt L or L on macOS)
    4. Enter your find and replace characters in their inputs
    5. Click the Replace all icon

    It works but you have to go through the workflow all over again for each new selection (except for CTR + H of course). BTW I have the exact same behavior in Sublime Text.

    Could you go with a regExp to find your lines? Do they contain only .'s and 1's?

    0 讨论(0)
  • 2020-12-25 11:22

    From the VSCode devs:

    We used to enable find in selection automatically when opening the find widget with a selection, but it was too easy to trigger accidentally and produced a lot of complaints. You probably want to set "editor.find.autoFindInSelection": true which will make it work the way you expect.

    The VSCode GitHub issue has more details if anyone is interested.

    EDIT: The autoFindInSelection option is available starting from VSCode 1.13. That version is currently in development (as of 6/7/2017), so this fix won't work until the new version is released.

    0 讨论(0)
  • 2020-12-25 11:32

    This is a more general answer for other users who come here just wanting to use basic find and replace functionality.

    On Mac you can press Command + Option + F to open Find and Replace:

    Alternatively, you can press Command + F to open Find and then click the little triangle on the left to show the Replace field:

    0 讨论(0)
  • 2020-12-25 11:39

    On Mac:

    • Select the text
    • Press command + shift + L
    0 讨论(0)
  • 2020-12-25 11:39

    Since sometimes we might have similarly named things so you don't want to select everything, one of my favorites shortcut sequences is to select the next occurrence:

    1. Use shift and arrows to highlight the term you want to match.
    2. Use Ctrl + d to highlight the next occurrence of the term.

    The Basic Editing in VS Code documentation page has some extremely useful variations on find and replace. One extremely useful shortcut is the Column (Box) Selection.

    0 讨论(0)
  • 2020-12-25 11:40

    I found the following workflow to be fairly painless:

    1. Select text region with mouse or keyboard.
    2. Ctrl+H to toggle find and replace
    3. Alt+L to toggle find in selection
    4. Ctrl+Alt+Enter to replace all (or enter to replace individually)
    0 讨论(0)
提交回复
热议问题