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

Surround text with angle brackets, expand select to angle brackets boundaries #57162

Closed
infctr opened this issue Aug 24, 2018 · 6 comments
Closed
Labels
*duplicate Issue identified as a duplicate of another issue(s) editor-autoclosing Editor automatic closing of parens / brackets / etc. feature-request Request for new features or functionality
Milestone

Comments

@infctr
Copy link

infctr commented Aug 24, 2018

So we've got this nice surround text with special characters feature that includes (), [], '', "" and surrounds the selected text with corresponding characters just by pressing (, [, ', " key.

But there's no option to surround text with angle brackets that are used in Typescript generics for example. I've searched opened and closed issues, that's the only one related so far but no longer relevant. There's a nice extension that does that, but that's still requires a hotkey combination and not implemented on the editor level. That could be a really nice feature to wrap the selected text with a single < key press in the same fashion since Typescript is so tightly integrated into vscode. That could be an opt-in feature if it messes with some other user stories I'm not aware of. Or it wasn't implemented by some other decision?

angle-brackets

And there's another feature as Expand select that selects within boundaries (same characters again (), [], '', "") but doesn't respect angle brackets boundaries. That would be lovely to select text within angle brackets too.

Using Expand select here, selects within parentheses and braces, ignores angle brackets

expand-select

@vscodebot vscodebot bot added editor editor-bracket-matching Editor brace matching labels Aug 24, 2018
@rebornix rebornix added the feature-request Request for new features or functionality label Aug 26, 2018
@rivy
Copy link

rivy commented Sep 29, 2018

Additionally, is there any reason that "always" isn't an option here, or, at least, a default fallback for languages that which aren't defining or supporting it? It's quite jarring to lose bracket/quote surround when moving from one file to another.

@thany
Copy link

thany commented Nov 5, 2018

That could be a really nice feature to wrap the selected text with a single < key press

Disagree. Selected text should always be overwritten by characters from the keyboard. Otherwise it'll be inconsistent. I actually raised a bug report about this and the { character that already does what you want, which is exactly what I don't want.

If this is implemented, it has to be an option that can be switched on or off.

@usernamehw
Copy link
Contributor

Workaround for wrapping:

{
    "key": "shift+.",// should be `>` key
    "command": "editor.action.insertSnippet",
    "args": {
        "snippet": "<${1:${TM_SELECTED_TEXT}}>"
    },
    "when": "editorHasSelection"
},
{
    "key": "shift+,",// should be `<` key
    "command": "editor.action.insertSnippet",
    "args": {
        "snippet": "<${1:${TM_SELECTED_TEXT}}>"
    },
    "when": "editorHasSelection"
},

Expand selection was always kind of trashy in vscode #4795

@alexdima alexdima changed the title [feature] Surround text with angle brackets, expand select to angle brackets boundaries Surround text with angle brackets, expand select to angle brackets boundaries Nov 14, 2018
@Yanpas
Copy link
Contributor

Yanpas commented Nov 15, 2018

Surrounding with angle brackets works with c++ and java, but not with typescript

@infctr
Copy link
Author

infctr commented Nov 20, 2018

@usernamehw wow, thanks, that just works as expected

@alexdima alexdima added this to the Backlog milestone Aug 8, 2019
@alexdima alexdima added editor-autoclosing Editor automatic closing of parens / brackets / etc. and removed editor-bracket-matching Editor brace matching labels Aug 8, 2019
@alexdima
Copy link
Member

Let's track the first part of the issue, where <,> are not surrounding brackets for TypeScript in #38352.

The second part of the issue has been fixed in the meantime and the Expand Selection action now stops at those intermediate nodes.

@alexdima alexdima added the *duplicate Issue identified as a duplicate of another issue(s) label Oct 16, 2019
@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 30, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*duplicate Issue identified as a duplicate of another issue(s) editor-autoclosing Editor automatic closing of parens / brackets / etc. feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests

7 participants