Mac-native text editor that can syntax-highlight diff files? - macos

I do something like "svn diff > /mystuff/current.diff". I want to view this .diff file with syntax highlighting.
jEdit does it, but it's a huge beast and it takes a while to start up. I want something lightweight/native.
Smultron/Fraise, TextWrangler, TextEdit, Dashcode don't seem to highlight .diff files.
FileMerge seems to want to generate diff files, not show you existing ones.
TextMate does the trick, but it's not free. I'd feel happier dropping $50 US if I was going to take advantage of it for anything more than a diff viewer.
Are there any alternatives to jEdit or TextMate that I should consider?

You could try an OSX GUI for vim, like the full-featured MacVim or the lightweight vim-cocoa...
(For a rough feature comparison, you can see this mailing list comment comparing them...)

You might Versions, you can download a free demo version that will work for a limited time. You point it directly at you svn repository and you can compare versions.
http://www.versionsapp.com/

I currently use DiffMerge and it works really well for me. (I'm forced to use StarTeam and it integrates well with it)

Not an editor but you could use GIT or Mercurial and their Mac GUI clients to view the highlighted diffs in any files. The clients are free.

In a terminal, one can also use the command line version of vim (which I believe comes with the Xcode command-line developer tools).
Unfortunately, the command-line version of vim is not set up to do syntax highlighting by default, so there's a little bit of additional magic necessary.
For those not versed in vim, you need to know these three commands in order to view diff files:
vim <file> // open the file in vim
:syntax on // turn on syntax highlighting
:q // exit vim when you're finished
Vim is good at automatically recognizing diff files, so it's usually not necessary, but if for some reason vim doesn't recognize your diff as a diff, you can tell it which syntax to use:
:set syn=diff
If your diff is of source code, you might also occasionally want to toggle back and forth between syntax highlighting of the diff and syntax highlighting of the code; you can also set the syntax to java, c, php, mysql, or sh, among others.

Related

Is it possible to take two files open in VS Code and open them in Beyond Compare?

I have recently switched from Sublime Text to VS Code (WIN10). I prefer VS Code now, as it' so much better, but I have something I can't figure out, and it seems crazy that there isn't a solution.
The VS Code Diff display is no good for actually editing, so I use Beyond Compare for all my diff-ing and merging.
I've searched high and low and can't find anything like a replacement for the ST3 plugin "FileDiffs" (https://packagecontrol.io/packages/FileDiffs).
I already have Beyond Compare set as my diff tool in .gitconfig, and I have the VS Code extensions for diff-ing with remote tools "when using Git" -- but what about when you just have two arbitrary files open in VS code, and I just want to open them in Beyond Compare?? This appears to be impossible in VS Code without using some very inefficient workaround.
(maybe I need to learn how to port a ST3 extension to VS Code...)
Check out PartialDiff: https://github.com/ryu1kn/vscode-partial-diff
Quoted from its docs,
You can compare (diff) text selections within a file, across different files, or to the clipboard.
Compare text in 2 visible editors (i.e. tabs) with one action.

bash open a vi and then execute a vi register

I am currently trying to make a script that will take any number of arguments and create files for them. I have some registers saved in vi that I already have loaded with generic things I want in each file type.
So, I know that my shell can enter a file by typing vi "filename" but I am wondering if there is a way I could execute a register and then close the file, I suppose I could use my shell to append things I want to but it seems much more tedious which I am happy to do if you guys don't have any hints.
P.S. I have been looking online for way to open multiple tabs in the same terminal with only having generic Ubuntu without having to open a new terminal. But I think the only way to make this possibly happen is through programs I have to install, correct? Thank you for your time.
If you're trying to open files in an already-open execution of vim, then I think that'd have to be two processes:
outside process: to create the files (the one you planned to create)
inside process: (in your already opened vim) to load newly-appeared files (eg: like an automated :e new/file.txt)
wrt your PS: multiple files (buffers) is doable by default; a quickstart:
you can watch or read this screencast more about "buffers"
definitely shouldn't need new software
try this out yourself: vim ./foo ./bar (in a terminal)
:ls to see buffers you've opened (you'll see "foo" and "bar)
:buffer N to jump to one of said buffers
wrt "tabs" -- is that so that you can click? If so, maybe reconsider using vi (but if you're sticking to vi: you can find documentation to get tab-like UI if you really want, and again: no extra software).

How to control line endings output by lua DOS<==>Unix

I am using luadoc and running it on Unix and windows, unfortunately the output is different on each system because of the DOS/Unix line endings, this really confuses my source control as it thinks every file has changed (mercurial). How can I make lua use one or the other?
I know nothing about lua, but you might want to solve this at the SCM level, Mercurial has the EolExtension for that.
That being said, you're probably missing some feature of luadoc.
Mercurial FAQ 7.4

How to perform multiple find and replace in TextMate besides macro?

I have several regular expressions to find and replace text in documents in TextMate. I would like to be able to have them run in a batch. I made a macro and it worked, but any tiny modifications to the macro means re-recording the macro. And I can't seem to modify the regex within the TextMate interface. It's read-only for some reason.
Can I make it into a command? Does anyone know how? I tried to read the TextMate help about commands, but it wasn't much help. It seems I need prior knowledge of shell scripts or some sort (which I have none). Any advise in the direction would be great.
Thanx in advance.
First, it's possible to edit macros. Since this is the easiest solution for you, here is how you do it:
Record a new Macro and save it in TheBundleOfYourChoice
Reload Bundles via "Bundles" > "Bundle Editor" > "Reload Bundles"
Open the file "~/Library/Application Support/TextMate/Bundles/TheBundleOfYourChoice.tmbundle/Macros/NameOfYourMacro.tmMacro" in TextMate (you can access any path - including hidden ones - if you press Command-Shift-G while in the "Open File" dialog)
Change the XML-representation of the Macro to your needs
Reload Bundles again
Use updated Macro
This solution may be the easiest for you, because it doesn't require you to learn a scripting language and should be OK for minor changes. However another very reasonable approach is choosing a scripting language of your choice and simply build a command, which runs your regular expressions. You can use perl, python, ruby, bash and so forth. A simple solution should be bash with sed. sed is a small tool, whose only purpose is to process text and should be ideal for you. bash is the default scripting langauge, so should be no problem either. You will figure it out somehow and learn a lot. Give it a try! :)

Diff tool that allows saving the compare markup

Is there a diff tool that allows saving of the compare markup?
To clarify, I would like to save the actual comparison of the two files that shows the differences to send to someone for review.
EDIT
Lots of good answers here. In my case I already had a copy of Beyond Compare but didn't see the option. Thanks to John Saunders for pointing out the feature. It's "Session...Text Compare Report..." BTW.
My question was not specifically about Beyond Compare, so I am going to accept the answer that currently has the most up votes.
WinMerge is free and allows you to save the differences in various formats. It works well enough for me to not bother looking elsewhere, and I like the price.
There is also a portable version if you can't, or don't want to, install it.
You can do this with the command line diff if you're using Unix, though it sounds like you're not. Cygwin does bring a CLI diff, and Mac OS X ships with it.
$ diff <file> <other file> > mydiff.txt
Beyond Compare does this.
I use the Scintilla Text Editor (SciTE) to open a diff file generated by command line or WinMerge, and then export the RTF, and it preserves color highlighting of differences. I use this method especially when emailing short patches for review in-house, and I use Outlook, for example.
The process I used just now as an example:
# diff -U 1000 a.txt b.txt > diff.txt
# scite diff.txt
### Edit-Copy as RTF
### Paste into Outlook
http://imagebin.ca/img/nBG25am.png
WinMerge provides this functionality through the Tools->Generate Patch menu item. I use the MSYS tools on windows, so that I run GNU diff a lot, but once you get the output, I would use SciTE if you need something like the above.
ExamDiff does a comparison which is shown in a window. It can save a Unix-like formatted version of the differences. Also, the file-to-file comparison version of the program is free!

Resources