I am using VS Code for PHP development, and I often work with statements that span multiple lines, such as echo, if, foreach, and similar constructs. I need a quick way to select the entire statement, including line breaks, from the start to the end, without manually selecting each line.
For example, I have the following code:
echo '1 Line
2 Line
3 Line
...100 Lines
';
If my cursor is placed just before the echo statement, I want to select the entire statement (from echo to the closing semicolon ;), even though it spans multiple lines.
Current issue: VS Code's expand selection (Ctrl + Shift + Right Arrow or Cmd + Shift + Right Arrow) doesn't handle multi-line statements very well, as it expands the selection by words or blocks instead of selecting the full statement that spans multiple lines.
Is there a quick shortcut or alternative method in VS Code that allows me to select the entire multi-line statement from start to end in one action?
Any tips or extensions to make this process easier would be greatly appreciated!
I am using VS Code for PHP development, and I often work with statements that span multiple lines, such as echo, if, foreach, and similar constructs. I need a quick way to select the entire statement, including line breaks, from the start to the end, without manually selecting each line.
For example, I have the following code:
echo '1 Line
2 Line
3 Line
...100 Lines
';
If my cursor is placed just before the echo statement, I want to select the entire statement (from echo to the closing semicolon ;), even though it spans multiple lines.
Current issue: VS Code's expand selection (Ctrl + Shift + Right Arrow or Cmd + Shift + Right Arrow) doesn't handle multi-line statements very well, as it expands the selection by words or blocks instead of selecting the full statement that spans multiple lines.
Is there a quick shortcut or alternative method in VS Code that allows me to select the entire multi-line statement from start to end in one action?
Any tips or extensions to make this process easier would be greatly appreciated!
Share Improve this question asked Mar 14 at 3:13 user5005768-hduser5005768-hd 1,4693 gold badges30 silver badges66 bronze badges 1- In my totally humble and subjective opinion, that is precisely how Expand Selection should work, and failing to do so means oversight or flawed implementation, so it wouldn't make sense to have a different command. What would it be, "Expand Selection Semantically"? It's a totally valid question, anyway. – Álvaro González Commented Mar 14 at 9:53
2 Answers
Reset to default 0Assuming you're using Windows, you can use the following shortcuts:
Select the next occurrence (while keeping the last selected words):
Ctrl + D
Select all occurrences:
Ctrl + Shift + L
Undo last selection:
ctrl + u
Now, your cursor will be placed in all occurrences.
If you don' t like any of the built-in commands for this, you can easily set up a custom keybinding with an extension, Jump and Select, that I wrote. A keybinding like:
{
"key": "ctrl+a", // whatever you want here
"command": "jump-and-select.jumpForwardSelect",
"args": {
"text": ";"
}
}
will select from the cursor to the next :
character. Alternatively, you can omit the args
and when you trigger that keybinding it will select to the next character you type (or <kbd>Escape</kbd> to resume normal input. Actually, if all you want to do is the second thing, you don't need a keybinding at all, as there is a built-in keybinding of Shift-Alt+F which does the same thing.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744675288a4587288.html
评论列表(0条)