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

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.

Related

how to add different number at end of multi line edit?

Having trouble finding a way to do this, maybe it is not even possible?
In my case, for testing flow of if-statements/user-interaction, am temporarily adding 40 lines of console.log('trigger-fired-1'); throughout our code.
However, to tell them apart would like each to end with a different number, so in this case, numbers one to forty like so:
In the screen recorded gif, to replicate what I am going for, all I did was copy/paste the numbers one to nine. What I really would like is a shortcut key to generate those numbers at the end for me to eliminate that step of typing out each unique number.
Am primarily coding in Visual Studio Code or Sublime Text, and in some cases shortcuts are similar, or at least have same support but for different shortcut keys.
There are a few extensions that allow you to do this:
Text Pastry
Increment Selection
NumberMonger
For Sublime Text, the solution to this problem is the internal Arithmetic command. Something similar may or may not be available in VS Code (possibly with an extension of some sort) but I'm not familiar enough with it to say for sure.
This command allows you to provide an expression of some sort to apply to all of the cursor locations and/or selected text.
By way of demonstration, here's the example you outlined above:
The expression you provide is evaluated once for every selection/caret in the buffer at the time, and the result of the expression is inserted into the buffer (or in the case of selected text, it replaces the selection). Note also that when you invoke this command from the input panel (as in the screen recording) the panel shows you a preview of what the expression output is going to be.
The special variable i references the selection number; selections are numbered starting at 0, so the expression i + 1 has the effect of inserting the selection numbers starting at 1 instead of 0.
The special variable x refers to the text in a particular selection instead. That allows you to select some text and then transform it based on your expression. An example would be to use x * 2 immediately after the above example (make sure all of the selections are still present and wrapping the numbers) to double everything.
You can use both variables at once if you like, as well as anything in the Python math library, for example math.sqrt(i) if you want some really esoteric logs.
The example above shows the command being selected from the command palette interactively, where the expression automatically defaults to the one that you want for your example (i + 1).
If you want to have this as a key binding, you can bind a key to the arithmetic command and provide the expression directly. For example:
{
"keys": ["super+a"],
"command": "arithmetic",
"args": {
"expr": "i+1"
},
},
Try this one ...
its not like sublime
but works g
https://github.com/kuone314/VSCodeExtensionInsertSequence

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.

Customize Expand Selection

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.

Replacing a string in Rubymine with a string with newlines

I want to use the Search and Replace dialogue in Rubymine, or something similar to replace something like "Scenario:" with "#Desktop\nScenario"
I'm trying to replace every instance of Scenario: in a large Cucumber test suite with
#desktop
Scenario:
Any best ways to do this?
Update:
Thanks to #ryan2johnson9 comment, I realise there's now an easier option (tested on 2017.3).
By clicking on the "New Line" (or using the shortcut Ctrl+Shift+Enter / Alt+Enter), the input becomes multilines.
Original Answer
In the search and replace box, if you tick the "Regex" option you can do:
Search: "Scenario:"
Replace by: "#desktop\nScenario:"
The only trick is to tick the "Regex" option :)
Rubymine has macros (http://www.jetbrains.com/ruby/webhelp/binding-macros-with-keyboard-shortcuts.html) but I dont think they are powerful enough for this example.
It's possible that you could solve it with some elaborate feature hidden inside Rubymine, but I think it would be a lot easier to do this with a tool like perl/sed from the Terminal. If you are using Windows I assume you could search the net and find a text search/replace tool that fits your need.
In OSX I there are a bunch of Text Substitutions app too.
I would go that route since Rubymines macro tool isnt up to the task.
Here's a cheap and sleazy alternative:
Copy a newline character from between two empty lines in the file being edited. Temporarily add two empty lines if you don't have any.
Set up search/replace and enter the string you want to replace into the search text input box.
Paste the newline you just copied into the replacement text box plus whatever other text you want. You will be able to see the height of the replacement text input box grow vertically by one line due to the newline.
Perform the search/replace.
For this, the use of the Rubymine regex is optional.

Length of current selection in Eclipse

Do you know any easy way to find out what is the length of the current selection in Eclipse?
i.e. I select a line fragment and would like to know how many characters are there?
Usually, I count them manually, but that's stupid. When being desperate, I move to the start, check the column number, move to the end, check the column number, subtract, think a minute if I should add 1 or not... and my selection is lost.
On Windows, Notepad++ is a good solution. Open a new tab, copy and paste in there and the length of the document listed at the bottom of the window is the number of characters you have.
Easy way? Copy the text and paste it to a counting script, like this site:
http://charcount.com/
(Warning: the site's background may hurt your eyes.)
Eclipse does support a Selection object, if you're into its API:
http://www.eclipse.org/articles/Article-WorkbenchSelections/article.html#example