Is there a function or a method to add " , " after every row in VSC? - visual-studio-code

I have a .json file which is about 600+ lines and it looks like this:
{data0..}
{data1..}
{data2..}
To use it i need to add [ before and ] after to make it an array (no problem)
but i need to add " , " after every row. Is there a function/method to do that faster than manual typing?
Every object contain data in it.
Or anything to make it readble?

Alternatively, and simpler,
Ctrl-A to select all.
Shift-All-I to put a cursor at each line end.
Type your ,.

Press Ctrl-H for the Search-Replace window
In the first line type \n which means new line and make sure the regular expressions button is pushed - it's 3rd in the row and looks like this: .*
In the second line type ,\n - to replace new line with a comma followed by a new line
Push the "replace all" button
Notice: it assumes every JSON object occupies strictly single line

Related

How can I automatically delete dates and times in rows with EmEditor?

I have a text file.
There are hundreds of different filenames in the text file.
However, it says different date and time at the end of each file.
Sample: life-in-cosmos-2021-11-11-12-45-46 or life-in-cosmos-2021-11-11-12-45.
In order to change the names of the files in bulk, I first need to delete the dates in this text file.
So I want to automatically delete the dates and times in each row.
However, I don't know anything about this.
And I don't know how to use macros.
Therefore, if there is a solution for this, can you provide an answer with a picture or video?
In order to explain my request more clearly, I present 2 examples.
Example:
Original Text: cosmos-lights-colors-T5DAPC-2020-09-11
The result I want to do: cosmos-lights-colors-T5DAPC
Example 2:
Original Text: cosmos-lights-colors-T5DAPC-2021-04-02-12-37-49-utc
The result I want to do: cosmos-lights-colors-T5DAPC
Assuming a date is always at end of each line, you can replace a regular expression with an empty string. To do this:
Press Ctrl+H to bring up the Replace dialog box, and set following options:
Find: -[0-9]{4}-[0-9]{2}-[0-9]{2}[0-9\-]*?(\-utc){0,1}$
Replace with: (blank)
Set the Regular Expressions option
First, click the Find Next button to highlight matches to make sure they are correct. If the matches are incorrect, you will need to adjust the regular expression.
Finally, click the Replace All button to remove all matched strings.
Before replace
cosmos-lights-colors-T5DAPC-2020-09-11
cosmos-lights-colors-T5DAPC-2021-04-02-12-37-49-utc
After replace
cosmos-lights-colors-T5DAPC
cosmos-lights-colors-T5DAPC

[LibreOffice Writer]: How to create empty line space after every period in a paragraph in LibreOffice Writer?

How to create empty line space after every period in a paragraph in LibreOffice Writer as like below:
Original Paragraph:
aaaaaa.bbbbb.cccccc.ddddddd.
Expected Paragraph:
aaaaaa.
bbbbb.
cccccc.
ddddddd.
If it is possible as per my expectation using LibreOffice Writer means guide me to get the above output. Thanks in advance.
Position your cursor at the start of the paragraph in question. Then in the Find & Replace dialog...
Check Regular expressions under "Other options"
Set Find: to \.
Set Replace: to &\n\n
Click the "Replace" button repeatedly until the paragraph changes are complete (Note that the first click will likely just position the cursor at the first '.')
For the whole document, do the same except position your cursor at the start of the document and click the "Replace All" button rather than "Replace".

JTextArea appending and deleting problems

I have a jTextArea that displays the clicked item from a jTable. I have a running code already and I am able to display the strings into my jTextArea. However, I have an issue whenever I try to remove a string.
So far, below is my code for getting the string value from the clicked item in jTable:
c = jTable2.getModel().getValueAt(jTable2.convertRowIndexToModel(selectedRow), 1).toString(); // this will get the name of product from a table and store it into C variable
The string from above code will be displayed on my jTextArea, as shown below:
jTextArea1.append(c + "\n");
Now, whenever I click an item to my jTable this will be stored into c variable, and the new item will be appended on my jTextArea with next line.
My sample output in jTextArea of this will be:
Apple
Mango
Now, I want to delete a specific string from that jTextArea, which I am able to do so in my current code. I am using this line of code to do that:
jTextArea1.setText(jTextArea1.getText().replaceAll(c, ""));
But then, whenever I clicked my jTable once again to append a new item, it will be appended next to the empty string, sample output is like this:
// from here is the beginning of the jTextArea
Mango
Apple
Now, I got empty strings before the new text is displayed.
In conclusion, I have understood that I never deleted an item from my jTextArea, but what it did was only to replace the string into an empty one. My problem is that I want to be able to append a string, then delete it whenever I need to do so without affecting the other appended strings, and without having an empty string.
Is there any other way to achieve this in replacement of my "replaceAll" line of code?
What you are asking for is analogous to editing a line of text to delete something in the middle. Naturally, you usually do not want a gap. One way to do this would be to copy the line over character by character but with a rule that if a space was preceded by a space it will not be copied (or, if a space comes up and is copied, then only characters will be copied that are not a space in that instance).
You could copy a series of records by reading each string, checking whether it had only spaces in it, and adding that string to the second screen only if it was other than white space.

How to edit all lines in Visual Studio Code

I have a list of data to which I need to put a ' symbol at the start of the line and at the end of the line. So the original data looks like this:
abcde
cdeab
deabc
eabcd
And I want all of the lines to look like this:
'abcde'
'cdeab'
'deabc'
'eabcd'
In my real data, I would have 10,000 of lines. So if I can do something like Ctrl+Shift+A to select the entire document and then have some magic shortcut to change from selecting all lines to editing all lines that would be perfect!
You could edit and replace with a regex:
Find (Ctrl+F):
^(.+)$
Replace:
'$1'
This regex finds any content on a line and wraps it inside quotes. The $1 refers to whatever is matched inside the parentheses in the regex. In this case, it's "one or more characters" i.e. everything on the line. Be sure to tick the regex icon.
If every line may or may not have a space before the content, and you want every line to have a space, try this:
Find:
^ ?(.+)$
Replace (notice the space before the first quote):
'$1'
Here is an easy way to do this:
Ctrl+A to select all or select your desired text.
Shift+Alt+I to put a cursor at the end of each line.
Type your ' (or whatever you want at the end).
Home will move all your cursors to the beginning of the lines.
Type your ' (or whatever you want at the beginning of all the lines).
You can use the Alt + Shift shortcut.
First press Alt + Shift then click the mouse button on the first line.
Go to the last line, and then do the same.
This will mark all the parts of one side. Whatever you type will be reflected in the marked spaces.
Do the same on the other side too.
Use Toggle Multi curosr Modified from action pane.
Select the cursor points with ctrl + <Mouse click> , you can modify everything simultaneously.
This will require lots of manual efforts if lines are more
You can use Find and Replace.
Besides, paste to Excel and using a function to add character '.
The first thing that came to my mind - replace abcde with 'abcde' line by using option Find and Replace option. I'm pretty sure Visual Studio Code has something similar to that.
You can use the Shift +Alt shortcut for windows and for Mac use Shift + Option
First press Alt + Shift/Shift + Option then click the mouse button on the first line.
This will mark all the parts of one side. Whatever you type will be reflected in the marked spaces.
Place Cursor where you want to insert/delete text.
Goto Selection Menu and choose Column Selection Mode
Scroll to the bottom of the data and shift + click in the last line where you placed the first cursor.
Perform action (add/delete whatevs)
Repeat for whatever other areas you want to change.
v: 1.74.3
1- You can use the Ctrl + H shortcut (menu Edit → Replace)
Enter abcde in Find Control.
Enter 'abcde' in Replace Control.
Then press Ctrl + Alt + Enter.

Can I make a macro in n++ that does a search/replace?

I'm new to n++, but I have been most impressed with this tool so far. I've been trying to record a macro that do a search/replace, but the 'search' part seems to have the initial search text from the recording 'hard-coded' in the macro.
What I want is:
Manually locate the cursor at the beginning of the first line of a fixed format code segment, then Macro actions:
move cursor two lines down
move cursor right x characters
mark charters from pos x to x+n
search and replace all occurrences of the selected text with "{p_'selected text'}"
In an more advanced version, I'd like to add some logic to step 4: only execute the replace part if the # of occurrences are > 1 (e.g. by first adding a count statement, but I'm not sure how to obtain the returned count # from the dialog box)
Is this possible?
While I'm a big fan of Notepad++, this sounds like something I would accomplish with AutoHotKey. You would select the text and copy it to the clipboard. AutoHotKey would read the clipboard, replace the text as you desire, and either replace the clipboard contents, or send it back to your document. Let me know if you would like to go that route.