How to enable single match under cursor?
For curly brackets and round brackets single pair is highlighted.
You can change the font background color in Visual Studio 2022's tool -> options.
In addition, Visual Studio enables single match by default(Click once on brace).
Maybe you changed settings, try resetting options.
Tools -> Import and Export settings -> Reset all settings.
Related
I get this functionality by default with WebStorm. On clicking a closing bracket, it temporarily displays the line with the opening bracket on top of the editor (if the line is not within the viewport) and hides it when I click somewhere else. I don't have to jump to the matching opening bracket to see it.
I have no idea what this functionality is called and I looked up many possibilities and couldn't find anything. Please help!
I have script tags everywhere in CSHML files. Something like below
<script src="~/Areas/Users/Somefilename.js"></script>
Using the regular expression i want to replace it using Visual Studio 2017 find and replace with the following
#Scripts.Render("~/Areas/Users/Somefilename.js")
The path parameter remains the same.
So based on the SO post
In find box i put <script src=.*></script>
and in replace box i put #Scripts.Render($1)
it finds the line in cshtml but replace does not work. It actually puts $1 instead of the path. #Scripts.Render($1)
Just wrap you .* in brackets like this (.*). This will capture the value and enable the replacement.
I'm using Visual Studio Code 1.14.2, and I'm trying to change name of variables to camelCase eg.
set_nominal_wavelength to setNominalWavelength.
Regular expression: _([a-z])
Replace: \U$1\E
does not work. Any idea how to achieve it?
As of vscode v1.75 there is a Transform to Camel Case command. So you could
Find: (_[a-z]+)+
Alt+Enter will select all those
trigger the Transform to Camel Case command
Pretty easy.
In the 1.47 Insiders Build support for the replace case modifiers (\L, \l, \U, \u) has been added to vscode. And so should be in the 1.47 stable release).
So simply doing your find: _([a-z])
and replace with \u$1 (since you only want to capitalize the first letter) works nicely in the Insiders Build now.
Works in both the Find Widget and the Search Panel.
There is a workaround:
Open Replace dialog and enter regex: _([a-z])
Then move focus to the editor area and press Ctrl+F2 ("Change All Occurrences")
Then change case of selection (Ctrl+P >upper)
Then press Left Arrow key and press Delete key
You may use other tools that support change case operators, like Notepad++, sed, R (gsub with perl=TRUE), but VS Code does not support these operators in the replacement pattern.
See this feature request on GitHub:
This is cool to have. This is beyond the scope of what is currently supported by javascript.
We need to come up with our own advanced replace engine to support these cases.
So there is already a post on how to remove trailing whitespace for IntelliJ, but there are claymores invisible to the naked eye as usual:
Remove trailing whitespace on save in Intellij Idea (12)
However, there is a C++/C editor derivative of IntelliJ, which is called Clion, and unfortunately no such checkbox exists as in the same location as in the link. So I can't use a mine detector.
I can't find anywhere in the internet how to automatically remove trailing whitespace on save in Cion. If anyone knows where the setting is, please let me know. Thanks, and call me Mr. X.
It's under File -> Settings -> Editor -> General -> Other:
I am trying to find all using statements that are in cs files that contain a reference to a class anywhere in the file following it.
For example, I want to match using Example.Foo; if BaseClass<SomeClass> is found anywhere in the file following it.
Like such:
I've tried (using Example.Foo;)(?=[.\s\n]*BaseClass\<SomeClass\>[.\s\n]*) but no joy...
UPDATE
For clarity, this is for the VS 2012 IDE Find and Replace dialog.
You need to add a (?s), which enables multiline matching, and also escape the period in using Example.Foo. The regex should be something along the lines of:
(?s)using Example\.Foo;(?=.*BaseClass<SomeClass>)
I figured it out myself.
(?s)using Example\.Foo;(?=(.*|\s\r)BaseClass\<SomeClass\>(.*|\s\r))
This does the trick!
Thanks for the (?s) hint, that was required! +1 for that...