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

Expand selection and shrink selection in HTML #1808

Closed
oliverjanik opened this issue Jan 6, 2016 · 26 comments
Closed

Expand selection and shrink selection in HTML #1808

oliverjanik opened this issue Jan 6, 2016 · 26 comments
Labels
feature-request Request for new features or functionality

Comments

@oliverjanik
Copy link

Continuing from here: #495

Expand Select and shrink select work OK in typescript, json and JS. It seems it's not implemented for HTML.

@joaomoreno joaomoreno added the feature-request Request for new features or functionality label Jan 6, 2016
@joaomoreno
Copy link
Member

@jrieken ping

@esko
Copy link

esko commented Jan 26, 2016

Seconding this. It would be useful for both selecting content inside HTML element and selecting attribute values/names.

@oliverjanik
Copy link
Author

And extending selection hierarchically up the element tree.

@sortegam
Copy link

+1

@JimNewkirk
Copy link

Let me upvote this as strongly as possible. HTML is so highly structured, and in such a variety of ways, that selection of specific tags and strings is really crucial to working quickly and well. Without this feature, editing becomes not just unhandy, but too error-prone for my purposes. It would transform the utility of the editor if the same selection abilities were present in HTML as in other languages.

@oliverjanik
Copy link
Author

If anyone is looking for a reference Resharper for Visual Studio does this really well.

@bodiam
Copy link

bodiam commented Dec 19, 2016

IntelliJ is also quite at this, but Visual Studio code is quite lacking in this. I'm commenting on this because expand selection is my most used shortcut in IntelliJ, and I tried the same in Visual Studio Code, just to find out it's basically not working. I'm hoping someone might find the time to improve this feature.

@kaiwood
Copy link
Contributor

kaiwood commented Dec 19, 2016

Just in case it helps someone, I link to my answer to this topic from Stackoverflow a while ago: http://stackoverflow.com/questions/40949929/how-do-i-select-the-insides-of-div-in-visual-studio-code/40971959#40971959

It's not perfect, but with this keybinding setup, you basically use Emmet's selection / balancing commands in HTML files and standard shrink / grow for everything else. Works for me, the only caveat is that you can't "shrink back" to the selected attributes.

@JimNewkirk
Copy link

Very helpful, kaiwood - thanks.

@mtunad
Copy link

mtunad commented Jun 4, 2017

In case if anyone out there is still looking for this feature, see expand-region extension. It might help at the moment.

@Maxhodges
Copy link

+1 two years on and this feature still sucks. it skips many levels of hierarchy in HTML, going from current link to entire file instead of climbing nested levels of tags. IntelliJ (Webstorm) does this right.

@scottbickell
Copy link

Any updates on this? Expand selection is terrible. In an HTML doc, the selection goes from one word, one line, to entire document. As @Maxhodges said, IntelliJ IDEs do this right and it is one of the main reasons I continue to use their products instead of VS Code. Come on people, figure it out.

@TranMacTien
Copy link

nice!

@Maxhodges
Copy link

can I pay money to someone to make this happen?

@Maxhodges
Copy link

Maxhodges commented May 8, 2018

I documented the difference between webstorm and vscode expand select here in animated gifs

#4795 (comment)
seems comment maybe be folded (expand hidden comments)

@anantoghosh
Copy link
Contributor

@Maxhodges @scottbickell use emmet's balance in/out instead for html/jsx.
as mentioned in #1808 (comment)
(balance in is still broken.)

2018-05-13_16-02-43

Try it from the command menu.

You can add shortcut for it as required.

  {
    "key": "shift+alt+right",
    "command": "editor.emmet.action.balanceOut",
    "when": "editorTextFocus && editorLangId == html && editorHasSelection"
  },
  {
    "key": "shift+alt+left",
    "command": "editor.emmet.action.balanceIn",
    "when": "editorTextFocus && editorLangId == html && editorHasSelection"
  },
  {
    "key": "shift+alt+right",
    "command": "editor.emmet.action.balanceOut",
    "when": "editorTextFocus && editorLangId == javascriptreact && editorHasSelection"
  },
  {
    "key": "shift+alt+left",
    "command": "editor.emmet.action.balanceIn",
    "when": "editorTextFocus && editorLangId == javascriptreact && editorHasSelection"
  },
  {
    "key": "shift+alt+right",
    "command": "editor.emmet.action.balanceOut",
    "when": "editorTextFocus && editorLangId == typescriptreact && editorHasSelection"
  },
  {
    "key": "shift+alt+left",
    "command": "editor.emmet.action.balanceIn",
    "when": "editorTextFocus && editorLangId == typescriptreact && editorHasSelection"
  },

@Maxhodges
Copy link

Maxhodges commented May 14, 2018

@anantoghosh that's kind of rubbish for me. Try on something with quotes. It should do word, the string inside quotes, then string with quotes
and when retracting it resolves to another string entirely

wrnjxhqsdvs9

@anantoghosh
Copy link
Contributor

anantoghosh commented May 14, 2018

I have created an issue for this #49777
let's see if we make any progress.
Balance out selection should be improved as well. Maybe create a new issue for that.

@octref
Copy link
Contributor

octref commented Jan 2, 2019

Currently, you can run "Emmet: Balance (ourward)" or "Emmet: Balance (inward)" command for this functionality.

There's plan to support Expand Selection for all languages, and we'll do it for HTML/CSS using emmet.

You can track the new feature in: #65925

@octref octref closed this as completed Jan 2, 2019
@Maxhodges
Copy link

Maxhodges commented Jan 3, 2019

sorry @octref but you misunderstand. Emmet outward falls very short of a good solution. Can you jump on a conference call so I can demo what you are failing to understand? I've documented this over and over. Emmet only considers tags, not text elements. In Webstorm it will expand to the current word, then words within quotes, then include the quotes, then the tag. Emmet just grabs everything in the tag. Often we use this to grab a word, or a string with or without quotes.

here's how Webstorm does it. (as I've already documented elsewhere over a year ago, but clearly you're not paying attention to specifics.

Users shall be able to successively select expanding logical blocks of code so that you can easily select any expression in the code by placing the caret somewhere inside it and pressing a shortcut.

Extends selection to the next containing node (for example, an expression, a paired tag, an entire conditional block, a method body, a class, a group of vararg arguments, etc.)

In plain text, with the caret anywhere in a word, the selection would extend to to the word, the sentence, the paragraph

Shrink does the opposite.

web33175778-27f4b1a0-d0a0-11e7-9d8f-de9fdf0e7228

@Maxhodges
Copy link

Maxhodges commented Jan 3, 2019

@octref try this with Emmet Balance in/out! It fails miserably. Please don't forget to reopen the issue when you are done.
wb33175780-28f81182-d0a0-11e7-96b7-21324684dd7e

@oliverjanik
Copy link
Author

Thank you @Maxhodges for investing time into this. I too feel strongly about good syntax aware expand/shrink selection, but it seems mostly ignored brushed off by people who have not experienced the joy of using it.

@octref
Copy link
Contributor

octref commented Jan 3, 2019

@Maxhodges JavaScript/TypeScript balance outward will be provided by TypeScript language service. See #4795.

I'll start with Emmet and improve it later to have more granularity.

@octref
Copy link
Contributor

octref commented Jan 23, 2019

This will be available in tomorrow's insiders:

html-selection

Feel free to open new issues if something doesn't work as expected.

@oliverjanik
Copy link
Author

Fantastic news!

@Maxhodges
Copy link

Maxhodges commented Jan 24, 2019

looking forward to it!

@vscodebot vscodebot bot locked and limited conversation to collaborators Feb 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests