Merging two files in Notepad - merge

Hi i have two long files both 30k lines long. Is there any way of merging them like that in Notepad++ or using other software?
1st line from 1st file: 1st line from second file

If you happen to have python on your computer, using itertools you can merge both files. Keep in mind that if one file ends before the other, whichever file keeps going will continue to put their lines into the output file.
from itertoools import izip
with open("outputfile.txt", 'w') as output:
with open ("firstfile.txt") as f1 , with open ("secondfile.txt") as f2:
for file1,file2 in zip(f1,f2):
output.write(f1)
output.write(f2)

For decades there have existed a command to do exactly this, paste. Example:
$ cat > file1
one
two
three
$ cat > file2
1
2
3
$ paste file1 file2
one 1
two 2
three 3
$
The free gnu version is currently part of coreutils, which I think is simplest to install via cygwin. If you need the separator to be exactly colon+space you can just pipe paste's output through sed 's/\t/: /'.

Here is a possible solution using Excel:
1.)
Open the first file with Excel (all the text should be in one column)
2.)
Open the second file with Excel (all the text should be in one column)
3.)
Go back to your first file and add a : to every row of the second column
4.)
Copy the first column of the second file and paste it to the third row of the first file
5.)
Save the combined file as *.txt file

this is not possible in Notepad as far as i know, so your best bet is Notepad++. is there a reason why you don't wanna use Notepad++?
EDIT: I see, i deserve that -rep :P sorry for not reading correctly.
What you do in Notepad++ is:
1. open Notepad++ and navigate to Plugins > Plugin Manager > Show Plugin Manager
2. look for and Check "Compare"
3. click "Install"
now what you do is you open your first file in Notepad++. after that, you open your second files inside the same window of Notepad++ and drag the second file to the middle of Notepad++ (so click and drag the second document to the middle of Notepad++) once you release, it will ask you what to do. Click on "Move next to eachother"
after you have done that, you can now click Plugin > Compare > Compare. this will comapre the 2 files and give you exactly whats different between them.
Sorry for putting the answer quickly without reading more carefully.

Related

How to rename multiple files in vscode (visual studio code)?

I wonder, if there is way to rename multiple files in visual studio code? I have tried to use find and replace, no luck.
Here is how you can do it on Mac. Right-click (or ctrl+click or click with two fingers simultaneously on the trackpad if you are using a MacBook) on the folder that contains the files that you want to have renamed. Then click Reveal In Finder. Then from within finder select all files you want to rename, right-click the selected files and choose Rename X items.... Then you will see something like this:
Insert the string you want to find and the string with which you want to replace that found string and hit rename. Done 🔨
There are a few Visual Studio Extensions that try to provide this functionality.
The first two I tried did not appear to work. There is an extension called Batch Rename which worked for me: https://marketplace.visualstudio.com/items?itemName=JannisX11.batch-rename-extension.
Here is how the extension works.
You highlight the files in the explorer, right-click, and select Batch Rename
The extension creates a text file with the names of the files you want to rename, one each line. Update the text file with the new names
Save the temporary text file from step 2 and the extension performs the rename.
VS Code only supports single file name. On Windows, to do batch rename, you can use one of the following
[CMD]
// Change the extensions of all .doc files to .txt
ren *.doc *.txt
// Replace the first three characters of all files starting with 'abc' by 'xyz'
ren abc* xyz*
[PowerShell]
Get-ChildItem *.txt | Rename-Item -NewName { $_.Name.Replace('.txt','.log') }
A comprehensive tutorial can be found here
brew install rename
rename s/foo/bar/g **/*
Not an option for Visual Studio Code (yet)...
...but in Sublime Text with the dired package you can enter rename mode with Shift + R.
This gives you a buffer with each file on its line:
D:\path\to\myfolder
first.file
second.file
third.file
...
umpteenth.file
Rename files by editing them directly, then:
Ctrl+Enter = apply changes
Ctrl+Escape = discard changes
While in rename mode you can use the full power of the text editor: edit all filenames at once with multiple cursors, transpose strings (to accomplish switch renames in one fell swoop), find and replace, the Text Pastry package can give you number ranges etc.
vscode-dired will not let you do this, renames are one by one.
You can not rename several files at the same time in vscode,.
The simplest way I found is using the free "everything" utility, it takes seconds to rename a bunch of files in one or several folders.
Open "everything" and filter the file list.
Select the files you want to change
pick "Change Name" with rButtom
Popup will display with old list, the new list, the old names and the new names, if you change the new name, the new list will change accordingly.
VS Code has no such type of facility yet or extension on it. But using vs code terminal as a cmd and run this command on the folder where you want to change all file names from one to another like I want to change my all view files from HTML to PHP.
rename *.html *.php
Renaming multiple files with a single shot is also called batch renaming.
This can't be done from within Visual Studio Code.
There are two ways to get what you want:
(A) Rename files one by one
Go to the Explorer view in VS Code's Side Bar.
Select a file you want to rename.
Press F2 or choose Rename from that file's context menu.
Continue with step 2 as long as there are files you want to process.
(B) Batch rename multiple files using other tools
Go to the Explorer view in VS Code's Side Bar.
Select a file you want to rename.
Press Alt+Ctrl+R or choose Open Containing Folder from that file's context menu.
This brings up the file explorer of your operating system.
Batch rename the files from there. How this is done in detail is beyond the scope of this answer (most of the time, it is just selecting all files to process and starting the rename-tool).
Perhaps the easiest more detailed way is by using VSCode Terminal tab (Ctrl/Cmd + J) and selecting from the dropdown menu the Powershell option:
Based on Kin's answer and the resource Kin provided (2nd page), in order to look into the current and all sub-folders, these are some useful renaming possibilities:
Extensions rename
ls -R *.txt | Rename-Item -NewName {[io.path]::ChangeExtension($_.name, "log")}
Selects txt files and renames their extensions to log.
Name+extension rename
Get-ChildItem -R *.txt | Rename-Item -NewName {$_.name.Replace('.txt','-text.log')}
Selects txt files and renames them to [ORIGINAL_NAME]-text.log.
NEW_NAME+NUMBER+extension rename (original names are discarded)
Get-ChildItem -R *.txt | %{Rename-Item $_ -NewName ("NEW_NAME-{0}.log" -f $nr++)}
Selects txt files and renames them to [NEW_NAME]-NUMBER.log.
How it works:
ls, an alias of the Get-ChildItem command (equivalent in Powershell), lists current directory files;
-R option allows the recursive lookup to happen;
listing result is piped into a multiple Rename-Item commands invocation.
You can rename a statement "in all files" highlighting it and then pressing "CTRL+R" and "CTRL+R"(again). That will replace the selected word/statement in the entire file and (if you don't disable the tooltip checkbox) in all other files where it matches.
I'm not sure if this answer your question, because this is for the text inside the files, not for the filenames.

How can I copy sequential parts of vim file into new files and naming those files with dates?

I have files that are 100000+ lines in length.
I would like to take the first n lines, cut them, and paste them into a new file named s20130115.txt (that representing the starting date), then save and close the new file.
Then I would like to take the next n lines, cut them, and paste them into a file named 20130116.txt, then save and close the new file.
The I would like to continue that process until the original file is empty.
Any thoughts?
TIA
If possible, you'll want to do this with awk or some other scripted editing tool instead; it will save you a lot of repetition. So I'm going to assume you can't for some reason; maybe the number of lines is different each time and there's no better way to tell than just by looking.
You can write lines from your file into a new file using the :w command with a range. For instance:
If you type 10:w foo.txtEnter, it will take ten lines starting at the cursor position and write them to the file "foo.txt". You can then delete those 10 lines with 10dd.
You can type :1,10w foo.txtEnter to write lines 1-10 of your file to "foo.txt" (counting from the start of the file, regardless of cursor position). Delete by entering :1,10dEnter.
You can select a range of lines by pressing V and moving the cursor. Once the range is selected, type :w foo.txtEnter to write the lines. Select the same range again with gv; then you can delete with d.

Sublime Text 2 - How to open a file from open folders using the command pallet?

I want to open a file using some kind of fuzzy searching, and I'm pretty sure I've seen this functionality inside Sublime Text, but for some reason I can't find any mention of this anywhere.
I want to open the command pallet and be able to type a file name in there, and if the file is close, It will open the file for me, if it's open, it will activate it's window and group.
Is this possible?
I see you already found ctrl+p, but the original announcement of this feature has some good information on usage so I thought I'd post it.
The biggest change here is that the Ctrl+P dialog has been reworked into a more general "Goto Anything" popup. From this, you can:
Type, to search through files (open files, recently closed files, and files in open folders)
#foo, to search through symbols in the current file
:foo, to go to the given line number
#foo, to do a fuzzy search in the current file for foo
These can be combined: "foo#bar" will search for the file that best matches "foo", and go to the symbol in that file that best matches "bar". "foo:100" would go to line 100 of the same file. You can use this to preview a location in another file, then hit escape to go back to where you where.

Is there a way to copy code from eclipse including ine numbers

I am writing a little bit of documentation and code explanation. I would like to copy code from eclipse including line numbers, so that it becomes easier to reference the code in the text.
Is there any way to do this in eclipse or some other IDE, editor?
Since Eclipse 3.4 and bug 19602, you will print the line numbers if you have activated them on the Eclipse editor.
alt text http://img706.imageshack.us/img706/7605/eclipseshowlines.png
Printing a source will give you:
alt text http://img341.imageshack.us/img341/9899/eclipseprint.png
You can do it by printing a PDF of source file, then copying source with line numbers from the PDF document.
It works for me with eclipse PDT + CutePDF, it should also work with Acrobat PDF printer
Another not-so-clean work-around to achieve this. This is specific to the Subversive plug-in.
3 steps to follow:
Delete the piece of code you need to copy and save the source file.
Right click the file and chose option Team -> Create Patch.. and save it to a file, say copy.patch
Undo (Ctrl + Z) the changes to revert the deletion done in step 1 and save the source file again.
Open the patch file and use the contents.
This also includes the file-name (if desired) along with the line number and retains the indentation.

What tool can do a visual comparison of two sections within the same file?

Good file comparison tools were already discussed to the pain, but my problem is more exotic. Is there any visual text comparison tool (like WinMerge) that would allow me easily do visual comparison on two sections within the same file?
I have multiple configurations within vcproj file and need to maintain them. It is a pain to do this manually -- splitting windows, scrolling character-by character. On top of that xml is very verbose and takes lots of screen real-estate. I cannot believe there is no tool to do automatic file section comparison, since this sounds like a very common problem.
Please, do not offer me to use property pages, I do not want more complexity, I want less. Splitting manually into files and then comparing them is also too medieval (I am doing this now anyways).
I use Beyond Compare (not free, but I think a shareware version is available). You can select the same file for left and right sides, then right-click the beginning of your section on each side and select "Align Manually". This would allow you to compare two sections of the same file relatively easily.
Overall, I highly recommend the product. I haven't tried version 3, which is what they currently have on their Web site, but version 2 is a fabulous tool. A+
Emacs Ediff.
I use UltraEdit for most of my text editing and they have a product called UltraCompare that does a visual compare.
Update by Mofi
UltraCompare Professional supports also a comparison of text snippets in addition to entire files.
After starting UltraCompare, select Text Compare in menu Mode if not already selected. Select in text editor the first text block which should be compared, press Ctrl+C, switch back to UC and paste with Ctrl+V the block into left text area pane. Switch again to text editor, select the other block in same file, press Ctrl+C, switch back to UC, click into right pane and paste the block with Ctrl+V. The two blocks are immediately compared and the differences are displayed.
Such a text snippet comparison for two blocks in same file can be started also directly from within UltraEdit. Select the first block in file, press Ctrl+C, Ctrl+N, Ctrl+V and Ctrl+A to copy, paste and reselect this block in a new file. Select the second block in file. Execute command Compare from menu File in UltraEdit with option Compare selected text automatically being enabled and click on button Compare. UC Professional is started with just the 2 selected blocks for comparison.
You can use Meld to do this
Open up meld without specifying file names
Meld with prompt which type of comparison you want. Choose file comparison
Meld will present the the icon to select the file names. Below that it will prompt for a Blank comparison. Choose that.
In the file comparison window, paste the sections of the file you want to compare.