Is it possible to create a function to manipulate a text selection? I'd like to select a paragraph and tell Visual Studio Code (or in any other text editor) to execute a function on that selection.
I've tried to use code snippets, but it allows only simple manipulation.
I've also tried to use regular expressions, but I'd like to execute different code based on which text I'm selecting. (As far as I've seen, the interface allows only 1 regexp at a given time)
Text example:
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){ }
I' like to select the wording (L1: Q4 (...) L10:Test2?) and press a shortcut to format as:
id: Q4
wording: |
Consider these classes ... Test2?
Then, select L11A. (...) L14{}, press another shortcut, and format as:
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){ }