How to add quote marks to string in Sublime? - sublimetext3

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.

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

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.

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.

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