Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New command, "Select to Bracket", that will select the text between ... #43371

Closed
user3323 opened this issue Feb 10, 2018 · 12 comments
Closed

New command, "Select to Bracket", that will select the text between ... #43371

user3323 opened this issue Feb 10, 2018 · 12 comments
Assignees
Labels
editor-bracket-matching Editor brace matching feature-request Request for new features or functionality verification-needed Verification of issue is requested verified Verification succeeded
Milestone

Comments

@user3323
Copy link

  • VSCode Version: 1.21.0-ins
  • OS Version: win7x64

https://code.visualstudio.com/updates/v1_20#_select-text-while-jumping-between-brackets
tells us:

There is a new command, Select to Bracket, that will select the text between two matching brackets (as opposed to the already existing command, Go to Bracket, which only moves the cursor to the matching bracket).

I'm not an expert in English, but I think "between two matching brackets" means, that brackets (parenthesis, etc.) should be excluded from this selection...

select the text between

.. shouldn't they?

@alexdima
Copy link
Member

I don't know what would be best, to select the brackets or not...

This came in as PR #39066 from @afonsobspinto

@alexdima alexdima added under-discussion Issue is under discussion for relevance, priority, approach and removed editor labels Feb 15, 2018
@afonsobspinto
Copy link
Contributor

Hey. That's a great question. We faced the same one.
We ended up opting to select the brackets too since it was @chrisdavies's preference in the PR #28163

I vote for selecting the brackets as well. I'm often trying to yank code, which generally includes the brackets.

I should try to add support for multicursors soon, so let me know if you want me to change the behavior too.

@user3323
Copy link
Author

@alexandrudima

how about to make an option?

  1. with brackets
  2. without brackets

@alexdima
Copy link
Member

We could add an argument to the command implementation.

It would be definable in keybindings.json like e.g.:

	{
		"key": "shift+cmd+\\",
		"command": "editor.action.selectToBracket",
		"args": { "selectBrackets": false }
	}

Those would be available in the last argument (not used now) for the run method:

public abstract run(accessor: ServicesAccessor, editor: ICodeEditor, args: any): void | TPromise<void>;

https://github.com/Microsoft/vscode/blob/1633d0959a33c1ba0169618280a0edb30d1ddcc3/src/vs/editor/contrib/bracketMatching/bracketMatching.ts#L61

@alexdima alexdima added this to the Backlog milestone Apr 18, 2018
@alexdima alexdima removed their assignment Apr 18, 2018
@alexdima alexdima added feature-request Request for new features or functionality and removed under-discussion Issue is under discussion for relevance, priority, approach labels Apr 18, 2018
@kanlukasz
Copy link

kanlukasz commented Jun 4, 2019

Is it possible to select without brackets now?
I looking for solution for selection without brackets because it's really useful.

Example - CSS rules sorting:

Step 1 - Select all without brackets
Step 2 - Run command - Sort lines Asc.

Above scenario is impossible right now :(

Ps. label smart-select should be added to this ticket i think :)

@serend1p1ty
Copy link

Let's say that there is a command called selectBracket.
Then selectBracket ( select the text between brackets does not include brackets themself.
selectBracket ) select the text between brackets include brackets themself.

@jsejcksn
Copy link

You might be interested in Shrink/Expand Selection

@yisibl
Copy link
Contributor

yisibl commented Sep 3, 2019

@alexandrudima @afonsobspinto Do you have the opportunity to support this?

I want the behavior of selectToBracket to continue to expand(editor.action.smartSelect.grow) like Smart selection.

@alexdima
Copy link
Member

There is now a new argument to the command, which can be used via keybindings.json, e.g.:

{
	"key": "shift+cmd+\\",
	"command": "editor.action.selectToBracket",
	"args": { "selectBrackets": false }
}

@alexdima alexdima added the verification-needed Verification of issue is requested label Oct 28, 2019
@jrieken jrieken added the verified Verification succeeded label Oct 29, 2019
@ReaperTech
Copy link

Does anyone know - is there a shortcut key for editor.action.selectToBracket ? When I search through Keyboard Shortcuts it is not listed.

@kanlukasz
Copy link

From what i know they didn't add this but it's not a problem because you can make your own shortcut:

{
    "key": "ctrl+shift+'",
    "command": "editor.action.selectToBracket",
    "args": {
        "selectBrackets": false
    }
}

@ReaperTech
Copy link

From what i know they didn't add this but it's not a problem because you can make your own shortcut:

{
    "key": "ctrl+shift+'",
    "command": "editor.action.selectToBracket",
    "args": {
        "selectBrackets": false
    }
}

Thanks @kanlukasz ! If anyone reading this wants to know where you place this text ->
press ctrl+shift+p and type Preferences: Open Keyboard Shortcuts, select the Open Keyboard Shortcuts (JSON) icon top right and add it in there.
image
https://code.visualstudio.com/docs/getstarted/keybindings#_advanced-customization

@vscodebot vscodebot bot locked and limited conversation to collaborators Dec 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
editor-bracket-matching Editor brace matching feature-request Request for new features or functionality verification-needed Verification of issue is requested verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants