I have large .sql file with (multiple inserts).
I want using sublime 3 to add per 5000 lines , one command like :
commit;
Is it possible ?
Thanks ijn advance
Using regex you can capture a line using : (.+\s) .
Then add a quatifier to determine the number of lines you want to capture: {5000}
And replace the Group of N lines by : "[Group of N lines][My new Text][newLine]"
It give you : `$0newData\n
Here is an exemple on a simple text file, with "newData" every 3 lines. And an online exemple.
Nb: Click the .*, to activate the "Use regex in find search" option.
Related
I need to prepare test data having around 10K lines with many blank lines, same has to be removed. Earlier I was using editplus (Text editor) and could able to solve very easily by using Find (Find text: "\n\n" Regular expression) and Replace (empty) option.
Here in this project I am using Sakura editor and tried the below option to remove blank lines but its not working.
Need to remove line 6 and 7.
Find text
\n\n
\r\n\r\n
[\r\n]+[\r\n]
More information about using of regular expression in sakura editor
Click here
PS: I have some restriction in my current project to download and install any other software/tools.
Any help is appreciated.
Finally found solution. Like to share with others.
In sakura editor, we can remove the empty lines by using find and replace option.
Find ^\r\n 【Option:Regular expression】 and replace
Explanation
^ Beginning of the line
\r carriage-return character
\n newline (line feed) character
I have one file and contains:
file2.txt
PRIMERB
PrinceValiant
Priory
PRISTINA
embossed
heavy
incised
light
Outline
ribbon
and
file1.txt
PRIMERB 333
PrinceValiant 581
Priory789
PRISTINA3!1
embossed509
heavy5#
incised999
light5*1
Outline937
ribbon-81
I'd like to combine/merge these two files together so they would be like :
PRIMERB 333 PRIMERB
PrinceValiant 581 PrinceValiant
Priory789 Priory
PRISTINA3!1 PISTINA
embossed509 embossed
heavy5# heavy
incised999 incised
light5*1 light
Outline937 Outline
ribbon-81 ribbon
How would I do this in notepad++?
Add space characters to the end of the first line of file1 until it is longer than the longest line in file1.
Do a column mode selection of the entire contents of file 2. Do this by holding the ALT key down while dragging the mouse across the file. As you drag you should see a rectangular area of the screen selected. It may be easiest to start the selection before the first character in the first line of file2. Could also do a column mode selection with just the keyboard. Hold the ALT and Shift keys down while moving the cursor with the arrow keys.
Copy the selected text. (Control-C or menu => Edit => Copy or context menu => copy.)
Paste after the spaces added to file1.
Remove unnecessary spaces.
If the existing spaces in files1 and file2 are important you might use a regular expression to alter every line in file2 to have some character or character sequence that does not occur in either file before selecting its contents. For example, find ^ and replace with !!. Then you can use another regular expression to remove only the spaces added by the paste. For example, replace _*!! (space, asterisk, exclamation-mark, exclamation-mark) with _ (space; note that spaces would show incorrectly in these two strings, so they are shown as underscores _ for clarity).
See also the Editing => Column mode editing section of the Notepad++ help pages.
Maybe you can try ConyEdit. It is a cross-editor plugin for the text editors, including Notepad++.
Follow the steps below:
1, keep ConyEdit running.
2, use the cc.gl a command line to push data to array a.
3, use the cc.gl b command line to push data to array b.
4, use the cc.p command line to print the contents of the array a and array b.
Gif Example
Instead of finding some way of automating this, I think it'll be easier for you to just copy & paste...
But that purely depends on how many rows of text you got in those text files. If they contain less then 50 lines, I suggest you just copy (or cut) and paste.
I wouldn't know any way to automate that in Notepad++ anyway.
Edit:
After your request I wrote a quick PHP script that takes the lines from 'file1.txt' and 'file2.txt' and combines it to 'file3.txt'
<?php
$files1 = file('file1.txt'); // read file1.txt
$files2 = file('file2.txt'); // read file2.txt
// Assuming both files have equal amount of rows.
for($x = 0; $x < count($files1); $x++) {
$files1[$x] = str_replace(array("\n", "\r"), "", $files1[$x]);
$files3[$x] = $files1[$x]." ".$files2[$x];
}
$result = implode("", $files3); // combines the array to a single string.
if(file_put_contents('file3.txt', $result)) { // puts the imploded string into file3.txt
echo "Writing to file 'file3.txt' was successfull.";
}
?>
Now I would like to help you best I can, but I cannot access my own domain at this time, and I have not yet wrote something for you to upload your own files to it.
You can run this your own by downloading the latest USBWebserver
1. Extract the files from the .zip you downloaded from the USBWebserver website.
2. Go to the just extracted 'root' folder.
3. Delete everything inside that 'root' folder.
4. Copy the code above and save it as 'index.php' inside the 'root' folder (you can do this with notepad++ too).
5. Move your 'file1.txt' and 'file2.txt' to the same 'root' folder.
6. Go up one folder and execute 'usbwebserver.exe'.
7. Click on 'localhost' when the window pops up.
8. If you get the message: "Writing to file 'file3.txt' was successfull." you should now have 'file3.txt' in that 'root' folder.
I know that it is possible to filter a search query in sublime to only look at/through certain filetypes, but I don't remember the syntax to do so. As far as I can recall, it was something like
..//filepath/ *.scss, *.css, *.xckv, -*.etc
Can anybody help me out here?
When you type 'MAJ+Ctrl+F'
You see the input at bottom of screen.
Line 1 : Find Input
Line 2 : Where Input
Line 3 : Replace Input
At right of Where Input, click on the three dots, and select 'add Include Filter'
I have an interview transcript with continuous text. At times, the names of the person speaking are written (Aron:, Kalle:, Tomas: etc.). I want to insert a line break before every name that is followed by a colon (:) (names, which I specify).
How can I script this in VIM so that when I run the command, it goes through the entire text file and insert those extra linebreaks?
In other words, I want to turn this:
Aron: bla, bla, bla
Kalle: yes, yes, yes
into:
Aron: bla, bla, bla
Kalle: yes, yes, yes
Try this simple command:
:g/^/pu_
g/^/ will match every line, then exec command below.
pu _ will put the text from register _(the black hole register) after current matched line.
You can also use the :substitute command:
:%s/$/\r
Yet another one which uses external sed:
:%!sed G
All commands have the same length. Pick one you like.
Try this
:%s#^\(\w*:\)#\r\1#g
- % : serach in all lines
- s : search and replace command
- # : separators (I perfer '#' to '/')
- \(\w*:\) : grep your required format (Aron:, Kalle:, Tomas: etc.) and store in \1
- \r : for inserting a line
- g : global search and replace
let's say I want to apply the following to lines 60 through 80 in a file that I am editing in vim.
:s/{/ {/
Is there a way to do this?
Thanks!
You can prefix your search command with a line range, e.g.
:60,80s/{/ {/
If you want the change to apply from line 60 and forward use :60,s. If you want to change the lines from current to 80 do: :,80s. You can even do :.+3,80s to apply the search between current line + 3 and line 80.
You can use several type of ranges as described here. And here are the official docs.
You can also mark the first line of the section that you want to apply the regex to with the m (mark) command. Then move the cursor to the last line of the section. Then the regex command becomes:
:'a,. s:/foo/bar/
which says, from the line marked 'a' to the current line, substitute foo with bar.