在所选内容中的Visual Studio代码中查找和替换 [英] Find and replace in Visual Studio code in a selection

查看:4
本文介绍了在所选内容中的Visual Studio代码中查找和替换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

我想将所有.替换为0。但是,当我突出显示该行并对.执行查找/替换时,文档中的所有都会被替换,而不只是我选择的行中的那些,即使我切换了"在所选内容中查找"按钮也是如此。这是个窃听器吗?在其他编辑器中,如果我选择一段文本,然后执行查找/替换,它将只查找/替换选定块中的匹配项。

以下是您应该能够重现该问题的代码片段。...............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. 控件+H打开查找/替换
  2. 选择您的文本行
  3. 单击右侧的"在选定内容中查找"图标<>Alt<>L<>或<⎇<>MacOS<>⌘<>L
  4. 在其输入中输入查找和替换字符
  5. 单击全部替换图标

它可以工作,但对于每个新选择,您必须重新执行工作流(当然,CTR+H除外)。顺便说一句,我在Sublime Text中有完全相同的行为。

您可以使用regExp来查找您的代码行吗?它们是否仅包含.和1?

这篇关于在所选内容中的Visual Studio代码中查找和替换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆