Search and Replace in Sublime 3 - sublimetext3

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.

Related

How to delete text before another text on every line

I have a list with oauth's, i have the format username:oauth:token, I need to get only tokens removing username and the oauth text on each line, like from UserCool:oauth:djhjwfjfwjfjwfj to djhjwfjfwjfjwfj, the problem is that i need to do that on every line so I cant just do remove everything before, how can I do it? (every software)
https://i.stack.imgur.com/mDVQ7.png
Notepad++ is good for doing this one-shot
Screenshot of the Notepad++ "Replace" window :
Here are the steps to follow:
Enter the expression ^.\*:.\*: inside the "Find What" text box
Enter an empty string in the "Replace With" textbox
select the Search Mode "Regular Expression"
click on "Replace All"

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.

Remove lines that doesn't contains a string with Sumlimes

I have 6 huge text files, and i need to filter them by deleting all the lines that doesn't contains the string: 53=S.
For 5 of them, i managed to filter the files with notepad++ as follow:
Find --> Mark --> Bookmark Lines --> Mark All --> Search --> Bookmarks -- > Remove Unbookmarked Lines
However, the application collapsed for a specific file each time i tried it. I tried it in two PCs with the same result.
Anyone know how can i remove the irrelevant lines with Sublimes or any other tool?
You could try a regular expression replace in notepad++.
Using notepad++, press ctrl+h or bring up the search>replace window.
In the 'find what' text box enter ^(?m)^(?:(?!53=S).)*$
and leave the 'replace with' text box empty
Make sure the search mode is set to 'Regular Expression' and then hit 'Replace All'
This should remove any line that doesn'tcontain the string 53=S
There is a notepad++ plugin called LineFilter (not LineFilter2), which provides a menu with entries like
delete all lines containing the selection
delete all lines not containig the selection
it opens a new tab with the result. That worked on large files. I liked it a lot.
The plugin is available from Notepad++ Plugin Central.
If you have grep available, then grep should do the trick, too.

Finding text, excluding supersets in Sublime

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'

Resources