Finding text, excluding supersets in Sublime - search

I remember hearing about the option to search for an exact word in Sublime, but I can't seem to find it.
What I mean by this is if I search for write, I'd like to exclude all instances of foo_write, foowrite, etc.
How can this be done?

Hit CtrlF (Win/Lin) or CmdF (OS X) to open up the Find tab. Make sure the first button on the left (Regular Expressions) is selected. In the search field, enter \bfoo\b and click the Find button or hit CtrlG/CmdG to search. The \b token indicates a word boundary, including spaces, punctuation marks like commas, periods/full stops, question marks, etc.

Also, the third button from the left, a pair of double quotes, says 'Whole Word' when you hover - Click this to find the exact word.
E.g., if I search for 'stage' it will return the line that contains the text 'when the stage changes' but not the line that contains the text '= b.stage__c'

Related

How do I remove every second character in all line with Emeditor

Example:
hRihdNeI
After removing letters: R , h , N , I
We get letter:
hide
Please note that there will be million of lines, all lines will have different length, they can be 5 characters long or even 50 characters long
If you use EmEditor, open the file, press Ctrl + H to open the Replace dialog box, click Advanced... and click Reset button to make sure all options are default, click OK.
In the Replace dialog box, enter:
Find: (.).
Replace with: \1
Set Regular Expressions and Match Case options, and click Replace All button.
After replacing all, some versions of EmEditor might have trouble refreshing the editor view. You can scroll up and down to see the changes. You can also press Alt + F3 to erase matching highlight. Finally, you can click the File menu, Save As to save the result as a different file name. I tested with a 10 million random ASCII text file.
Reference: Removing every other character in a string using Java regex

How to add quote marks to string in Sublime?

In Sublime text editor, I have a text as below (taking notes for nodejs in markdown format)
In Nodejs, command-line arguments will be stored in the process object and in the process object there is a property called argv(argument vector) and arguments will be stored in the form of array
If I want to search all process words and add markdown back-ticks quotes(`) around them, How can I do this in sublime ?
If there are no places where the string "process" is in the middle of a word, such as "subprocess", I would do:
Press Ctrl+f to open search.
Enter process in the search field.
Press Alt+Enter to select all coincidences.
Edit accordingly.
If I wanted to check each coincidence to avoid adding the quote marks erroneously I would instead do:
Press Ctrl+h to open search and replace.
Enter process in the search field.
Enter `process` in the replace field.
Click Find to see the next coincidence.
Click Replace or Find as necessary.

intelliJ -> is there any way to scope your search to be within a function

Very often while coding, I need to search for keywords which are common and happen throughout a large file, but I am looking for an instance within a function.
The default search functionality often gives me all results starting from the top. Is there any way/workflow to search only within a specific method/function or block of code?
Update
Do Ctrl + F
Then Ctrl + Alt + E
Type the text to search
On MacOS, it's cmd instead of Ctrl
Original Post
You can do it like this (mentioned keymaps are for Linux):
Let's take as an example the following code, where we will be searching for the word "key" inside the method "clear". As you can see there are many occurrences of that word (in red, highlighted the ones we want in our results, and in blue other occurrences, which we do not want to appear in our search results)
1- Select the area you want to limit the search scope to.
2- Press Ctrl+Shift+F. It will pop up a search window with the selected text pre-filled in the search box.
3- Select the options "Scope" and, in the combo next to it, "Selection" (if they are not selected by default)
4- Type the word(s) you want to search (in this example, the key word).
5- The results shown will be limited to the selected area. Notice how there are only 9 matches in the upper right corner ("Match case" option is checked), despite in the same file there are many other occurrences of the same word.
However, I was neither able to find a key combination in order to do this as a single action nor assign a new one. Also, notice how the search includes the text in the method documentation.
Tested using IntelliJ IDEA 2018.1.4 (Ultimate Edition), Build #IU-181.5087.20 on Ubuntu 18.04
Looks like we're finally getting this feature in IDEA 2019.3:
https://blog.jetbrains.com/idea/2019/09/whats-new-in-intellij-idea-2019-3-eap-2/ (Ctrl-F for subtitle "Ability to search in a selected area when using the Find action")
It’s now possible to search only in a selected area using the Find action (cmd+F / Ctrl +F). Simply select the code piece you need in the editor and invoke the Find action and the IDE will perform the search only in the selected area.
Screenshot from the article (was a GIF originally)
There is a way to search inside a method, however, it doesn't seem to work for other scopes.
When searching in file as usual, click "Find all"
You'll get a list of results in the bottom panel. If you enable "Group by file structure" (I had it disabled by default), you can get a list of matches for a particular method.
On IntelliJ in Mac:
In a file select the specific block in which we want to find
something
Press CMD + F
Press CTRL + OPTION + G
Notice that the cursor has automatically landed in the find toolbar's text field
Type in what is intended to be found
Press enter to move the cursor
to the first occurrence.

How to remove invisible line break character

I have big data at excel, and some cells contains html codes. These cells have line breaks in them. I tried to replace line breaks (Alt+010, \n) but excel said there is no char like this.
When I copied cell to notepad, there is no line break.
When I copied from notepad to phpmyadmin sql area or textpad, I see line breaks again.
There are notepad, textpad and phpmyadmin sql area screenshots below. How can I remove these invisible line breaks?
This could be a problem with Carriage Return + Line Feed. When you press Alt+Enter in Excel it only incerts a Line Feed. But if you somehow get both Carriage Return + Line Feed in a cell that could leed to additional problems. See this page for solutions:
https://www.ablebits.com/office-addins-blog/2013/12/03/remove-carriage-returns-excel/
Did you try to remove any unnecessary tab within the code? Also check for some trivial things like e.g string max length in your mysql database or editor's miscellaneous settings.
EDIT. oh, I forgot. It may be also caused by your language settings, check for default database's regional coding preset and if Turkish is currently supported.
Line breaks - do you mean the line breaks you could introduce in Excel with ALT+ENTER?
Then you could use Search / Replace option in Excel without need to copy your content to another tool:
Open it and introduce in Search for CTRL+J (you will receive a point displayed in the search field).
In Replace you could introduce what you want (nothing, a space, a semicolon, ...).
Select Replace all.
EDIT:
I've tested it by copying html from textpad to one cell using clipboard. With this the method described by me is not working.
But there is another solution: Open replace command, for "search string" introduce ALT-Key (keep it pressed), then introduce by using the numeric key pad (on the right side of a "standard" keyboard) the tree digits 0 1 0 and finally release ALT-Key (you will see a point displayed in the search field). Choose as replacement string what you want and choose replace all.
Function =clean() helped me. Find/replace with ALT+J worked to replace, but did not fully deleted all the invisible characters in the string, so the cell was still misbehaving with text in columns. The =clean() function finally removed all the invisible characters left there.

Search and Replace in Sublime 3

I've been googling like a madman, but for the life of me I can't figure out how to do these 2 things in Sublime Text 3:
Replace all occurrences of a string in the file tree, immediately.
Interactively replace or skip occurrences of a string in the file tree.
All I can manage to do is list and navigate the found matches. After that, I have to look at each file, manually alter the code and save.
In single file
Replace all occurrences of a string in the file tree, immediately.
Hit Ctrl+H, the prompt will open in the bottom of the window, the text of the button are self explanatory
Interactively replace or skip occurrences of a string in the file tree.
Hit Ctrl+H, the prompt will open in the bottom of the window, if you want to replace only this occurrence then click on Replace, if not then click Find, then will select only next occurrence of the search string and then click Replace. This way you can customize search and replace.
In entire directory or folder
Replace all occurrences of a string in the file tree, immediately.
Hit Ctrl+Shift+F, the prompt will open in the bottom of the window. There is a Replace button in the bottom right.
Interactively replace or skip occurrences of a string in the file tree.
Hit Ctrl+Shift+F, the prompt will open in the bottom of the window, Hit Find, then manually double click on the text (that you want to replace) shown in result (tab title Find Results) , that file will get open and replace there. In this way you can customize your custom find and replace in entire directory.

Resources