how it possible to search in atom or sublime text with Logical Operators - find

I wan't to know how can i use Logical Operators like
& (and)
or
|| (or)
in find and replace panel in sublime or atom editor.
tanx

Enable Regular Expressions (It's going to be the symbol at the bottom right that looks like .*), and then you can do something like #media|span in the search bar.

Related

Use matched groups in find and replace dialog of the Matlab script editor

This is a question about the Matlab editor. I have several recurrent texts in my script such as:
e_{pos}=%.3f, e_{vel}=%.3f\n
I want to remove the curly brackets around these terms, so I use the Find/Replace dialog to replace \{(\w+)\} with $1:
But, the editor inserts a literal $1 instead of the matched text (vel or pos). I know some editors use different characters than $ so I also tried \1 and #1 but they did not work either. The documentation does not mention it.
So, is it possible to replace a matched group in the Matlab editor? How can I do it?
Note: I am not asking for the Matlab code to do this, I want to do it in the editor.
Thank you!

RubyMine reformatting

This is in the RubyMine IDE.
It seems really simple but I can't find a way to do it. I want to take a line
[:a, :b, :c]
and as part of the reformatting rearrange each value to one line like so:
[
:a,
:b,
:c
]
And assign a nice little keyboard shortcut.
Any idea how I do this? RubyMine documentation isn't great.
Not familiar with a way to use the IDE reformatter for this need.
But, you can achieve the rearrangement using the find an replace tool (CTRL + R).
Mark the regex checkbox.
In the find box look for space - ().
In the replace box, insert newline - \n\t.
Then hit Replace all - it should do most of the job.

How can I convert tabs to spaces and vice versa in an existing file

I cannot figure out how to do this for the life of me apart from doing a find-replace on 4 spaces and converting to tabs (Version 0.10.2). I can't think of an editor/IDE that doesn't have a specific feature to do this. Does VSCode?
Since fix of: https://github.com/Microsoft/vscode/issues/1228 the editor supports it out of the box. Simply go for:
F1,
indentationToSpaces or indentationToTabs (depending on your need)
Enter.
Another way to do it is click the current indentation (Tab/Spaces:n) on the footer which will open your indentation options where you can select what you want to do.
If you are trying to convert non-leading tabs to spaces (or vice versa) you can use a regex search and replace.
Press CTRL + H
Click the .* button to search using regular expressions.
To search for tabs enter [\t] in Find box.
Enter spaces in Replace box and perform your replace.
Search box in regex mode:
To round out these answers, I will add my take for converting each tab to n spaces.
Highlight a tab character
Use CTRL + F2 select all occurrences
Press SPACE n times
This is the easiest way to do this (going beyond only converting leading tabs).
Note that this does not convert consecutive tabs to k spaces. It converts each tab. For consecutive tabs please see my comment on jrupe's answer. You will need VS Code find and replace with regular expressions to accomplish that.
Select Replace: CTRL-H
Enter Horizontal Tab in Find box: hold ATL and type 009 on the keypad.
Enter a space(or more spaces) into the Replace box: press space bar
Press Enter to begin replacing Tabs with Space(s).
Press F1 and then type into textbox convert indentation to spaces or whatever you want ones
On Visual Studio, Ctrl+K+F did the trick for me.
Fast forward to 2020/2021, there are some extensions that will give us that conversion. I have just needed that functionality (hence I found this article), and searching for extensions I found:
geocode.spacecadet - providing both TAB->SPC and SPC->TAB, but not updated since 2017, with 1.3k installs, 3.5 review
takumii.tabspace - TAB->SPC, from 2020, 1.5k installs, no reviews
pygc.spacetab - SPC->TAB, from... wait, literally yesterday! (or today depending on your TZ), 2 installs, no reviews

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.

Find and Replace in Xcode Using Regular Expression

I'm wondering, is there a way that you can do a search for all words that have the word "pPath" in them and replace them with "mutablePath" in Xcode. For instance, there are certain instances where there could be pPath_0 or pPath_50, I just want to replace them all with "mutablePath". Is there a regular expression I can use for this if it's possible?
EDIT #1: I mean to actually replace the whole word pPath_50 or (any word that has pPath in it) with mutablePath. Doing a simple find and replace will only replace the word "pPath" with "mutablePath".
EDIT #2: I found out that if you click the magnifying glass next to the search bar, then click "Show Find Options", you can select "Regular Expression" from a pull down menu and use it to do a search for a regular expression. I'm assuming that the regular expression language used for this is common to other things, does anyone know what the regular expression is to search for any word that has pPath at the beginning of it?
I found that you actually can use regular expressions on find and replace in Xcode 4.3. Simply click on the magnifying glass next to the search box (or the area where you enter in the text to search). Select "Show Find Options", then under "Style" choose "Regular Expression". I'm not too familiar with regular expressions, but I believe it uses syntax that is similar to a lot of other modules that implement them. For instance, I was able to solve my problem using "pPath_\w*".
Yes - Go to Search Navigator (left pane) - Click on the drop down for 'Find' and you will see replace.