在 Visual Studio 代码中查找并替换所选内容

2024-01-03

我在 VSCode 中编辑的文件中有以下行:

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

我想全部更换.s with 0s。但是,当我突出显示该行并进行查找/替换时.s, all the .即使我切换“在选择中查找”按钮,文档中的 s 也会被替换,而不仅仅是我选择的行中的内容。这是一个错误吗?在其他编辑器中,如果我选择一块文本然后执行查找/替换,它只会查找/替换所选块内的匹配项。

下面是您应该能够重现该问题的代码片段。这...............111.........111.............111..线在里面test_unicode功能。

def test_simple2(self):
        """Simple CSV transduction test with empty fields, more complex idx, different pack_size.

        100011000001000 ->
        ..........111....................111..........11111..........111..
        """
        field_width_stream = pablo.BitStream(int('1000110001000001000', 2))
        idx_marker_stream = pablo.BitStream(int('11101', 2))
        pack_size = 4
        target_format = TransductionTarget.JSON
        csv_column_names = ["col1", "col2", "col3", "col4", "col5"]

        pdep_marker_stream = pablo.BitStream(generate_pdep_stream(field_width_stream,
                                                                  idx_marker_stream,
                                                                  pack_size, target_format,
                                                                  csv_column_names))
        self.assertEqual(pdep_marker_stream.value, 63050402300395548)

    def test_unicode(self):
        """Non-ascii column names.

        Using UTF8. Hard coded SON boilerplate byte size should remain the same, column name
        boilerplate bytes should expand.

        100010010000000 ->
        2 + 4 + 9     2 + 4 + 6     2 + 4 + 7
        ...............111.........111.............111..
        """
        field_width_stream = pablo.BitStream(int('100010001000', 2))
        idx_marker_stream = pablo.BitStream(1)
        pack_size = 64
        target_format = TransductionTarget.JSON
        csv_column_names = ["한국어", "中文", "English"]

        pdep_marker_stream = pablo.BitStream(generate_pdep_stream(field_width_stream,
                                                                  idx_marker_stream,
                                                                  pack_size, target_format,
                                                                  csv_column_names))
        self.assertEqual(pdep_marker_stream.value, 1879277596)

我在 Ubuntu 16.04 中使用 VSCode 1.12.2。


我能够让它工作,但工作流程很差:

  1. control + H to open Find/Replace
  2. 选择您的文本行
  3. Click the "Find in selection" icon to the right Alt L or L on macOS)
  4. 在输入中输入您的查找和替换字符
  5. 单击全部替换图标

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.

你能用正则表达式来找到你的行吗?它们仅包含 . 和 1 吗?

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

在 Visual Studio 代码中查找并替换所选内容 的相关文章

随机推荐