0

是否可以创建一个函数来操作文本选择?我想选择一个段落并告诉 Visual Studio Code(或在任何其他文本编辑器中)在该选择上执行一个函数。

我尝试使用代码片段,但它只允许简单的操作。

我也尝试过使用正则表达式,但我想根据我选择的文本执行不同的代码。(据我所见,该界面在给定时间仅允许 1 个正则表达式)

文本示例:

1  Q4. Consider these classes, defined in separate source files, 
2  public class Test1{ 
3    public float aMethod(float a, float b) throws IOException {
4    }
5  }
6
7  public class Test2 extends Test1{
8  }
9
10 Which of the following methods would be legal at line 2 in class Test2?
11 A. float aMethod(float a, float b){}
12 B. public int aMethod(int a, int b) throws Exception{ }
13 C. public float aMethod(float a, float b) throws Exception{ }
14 D. public float aMethod(float p, float q){ }

我想选择措辞(L1:Q4(...)L10:Test2?)并按快捷方式将格式设置为:

id: Q4
wording: |
  Consider these classes ... Test2?

然后,选择 L11A。(...) L14{},按另一个快捷键,格式为:

alternatives:
  a: float aMethod(float a, float b){}
  b: public int aMethod(int a, int b) throws Exception{ }
  c: public float aMethod(float a, float b) throws Exception{ }
  d: public float aMethod(float p, float q){ }
4

0 回答 0