Customize Expand Selection - visual-studio-code

Is the behavior of Expand/Collapse Selection customizable? I want quotes to not be selected with an expansion. Also want to use other delimiters like periods, etc.
If a file isn't saved yet Expanding doesn't stop at quotes, but instead selects the entire line. Is this how Expansion is supposed to work with unsaved files?

I doubt the "Expand Select" command is customizable. Shift-Alt-RightArrow It is what it is.
However there is a nice extension that may act the way you want. Look at Expand Region. It will progressively expand or contract the region selected. If within a quoted portion, the first expansion will not select the quotes. It expands by region though, i.e., like scope. So it will not necessarily expand only to the end of the current line if that is what you are looking for.

Related

When double-clicking a number in VS Code, is it possible to have it ignore the unit? (ignore "px" in "12px")

When double-clicking a number:
100%: selects "100" (good)
100px: selects "100px" (bad)
To more rapidly change number values, it would be great if VS Code could ignore units of measure when double-clicking a number like it does with symbols.
This seems like a feature that would be part of Editor: Word Separators, but it looks like you can only add single characters to the list.
Does anyone know if it's possible to change this? Thanks!
With the extension Select By you can specify with an regular expression what you consider a "word" and with a keybinding you are faster than using the mouse in selecting.
Use the surround property, see the link.

vs code expand selection doesn't respect word separators setting

When I run the command "Expand Selection" with my cursor in a kebab-case-word-like-this, I want it to select the whole word including the dashes, but it breaks at the dash, even though my configured "Editor: Word Separators" (editor.wordSeparators) does not include dash (it's unchanged from the default). Any way to make it select the entire thing on the first expansion? Kebab case is the convention for clojure and this glitch makes it really tedious. It seems that deleteWordLeft and deleteWordRight also don't respect editor.wordSeparators.

Confluence Expand vs. UI Expand

Simple question: what's the difference between expand and ui expand?
I discovered a significant difference involving behavior.
UI Expand allows you to use expandable code blocks inside of it. Expanding and collapsing the nested code block does not affect the behavior of UI expand, whereas you cannot do this with regular Expand -- expanding/collapsing the nested code block also collapses the Expand, which is extremely annoying, and is one of the reasons why I'm looking into this in the first place.
If I come across anything else, I'll edit this entry.
EDIT: Another difference: using "#expand-(name of UI-expand)" in your URL goes to the UI-expand (as though it was an anchor) and expands it. This ONLY works with UI-expand; the regular expand will NOT do this. (It is for this reason why I included anchors before my expand macro, but apparently ui-expand does not need anchors. Even so, it only goes to the anchor; it does not expand the actual expand macro without any coding.)

VS Code Refactoring: Change all occurences - but only in block scope

When using "change all occurences" in VS Code, it will just search the whole file for matches and change them. Is there a similar feature doing the same thing, but limiting it to function or block scope?
Let's take an example where I would need that: I'm having a React file with several components and want to refactor a class component to a functional component, so I'm changing all occurences of this.props to props. However, I obviously don't want to change all the other class components as well that are supposed to stay class components. :-)
This seems like such a standard use case, but I'm not able to find it anywhere in VS Code. If it's not possible (yet, or for some good reasons) is there another way to achieve what I'm trying to do?
Check out the 'Add Selection To Next Find Match' functionality. It allows you to highlight the first occurrence you'd like to change, then using a keyboard shortcut, highlight the next occurrence and so on until you've selected all the instances you want to change. When all to-be-changed occurrences are selected, you can edit the selected text normally. Just remember to hit the escape key a couple times after editing to return to a single cursor!
Here are the keybindings for the command, it's Cmd+d on Mac:
https://code.visualstudio.com/docs/getstarted/keybindings
I find it very useful when renaming variables, there's also a shortcut to skip occurrences (Cmd+k Cmd+d) in case there is text you don't want to change in between.

Eclipse-RCP: Hide lines of text permanently, keep correct line numbers

I have text files which contain code inside an Editor. The user can run an analysis on a certain part of his code, which will result in a set of lines which should be hidden. Next I want to present the user with only the remaining lines, but with correct linenumbers, as from the original document. Possible solutions I thought of:
Open a new Editor which does not contain the hidden lines, but *somehow* still has correct line numbers
Hide the lines in the original editor, and offer a button for the user to 'unhide'. Probably a similar solution required as in 1.
I don't really know how to go about this. Folds would be a weird solution, because they can be unfolded individually, and seem to be more semantically tied to things like methods or classes. Also, simply creating a new document without the hidden lines results in wrong linenumbers.
Use a ProjectionViewer and reflection to invoke the private method ProjectionViewer.collapse(int offset int length). This method is only used internally to hide a certain portion of the text, by manipulating the ProjectionDocument (see http://eclipse.org/articles/Article-Folding-in-Eclipse-Text-Editors/folding.html).
After this, folding text in the editor using the annotations(the little +/- icons) WILL break everything, so this solution and regular folding are mutually exclusive.