Pasting diff output into Microsoft Outlook with syntax highlighting - outlook

How can I copy diff output (diff old-version.cpp new-version.cpp) into an Outlook email so I can send it to other people with syntax highlighting?
I'd either like to pipe diff output to a program that will copy it to the clipboard with formatting (p4 diff file.cpp | rtfpatch) or have a plugin for Outlook that lets me select some text, click a button, and it gets colorized.
I use Windows (XP and Vista), Perforce, Visual Studio, Beyond Compare 3, Outlook 2007. Anything using a combination of those tools would work great (I'm not looking to change my main diff program, etc...).

You can use Beyond Compare's "Text Compare Report" command in the Session menu to do this. Use the "Interleaved" layout style, the "HTML Report" output style and the "Copy to Clipboard" command and it will copy it to the clipboard as colored HTML. I don't have Outlook to test with, but it certainly works pasting it into Word.

Another decent solution I've found is a vim plugin. cliphtml.vim gives you the :ClipHtml ex command that will copy the whole file or the selected region to the clipboard with vim's highlighting.
Requires python.

Many editors have the ability to export syntax-highlighted files as HTML. From there, you can paste the HTML into Outlook. For example, to export a file to HTML in Vim, use :TOhtml.
This Visual Studio addon offers the "export to HTML" functionality as well. It's worth giving it a try.

To paste the html into into outlook you should try an past it into th source of the msg.
Right click the body of the HTML message and the select View source, then past your html into that.
The other way would be to script it in a batch file using and set the Message html body to equal your html text and send. There are quite a few examples of sending email via script on stackoverflow. There are a number of ways to do it depending what you have installed etc. one example is
Send mail from a Windows script
using CDO

I figured out a solution to make a batch file that diffs files from Perforce using the p4diff.exe program.
The problem with it is p4diff outputs the whole file, not only the changed sections (I'd also prefer unified diff). Also, diffing specific revisions requires calling rtfdiff from command line (the custom tool just diffs against HEAD).
p4v custom tool definition (write this to tool.xml and then import it in p4v's Manage Custom Tools menu):
<CustomToolDef>
<Definition>
<Name>RTF Diff</Name>
<Command>c:\scripts\rtfdiff.bat</Command>
<Arguments>%f</Arguments>
</Definition>
<AddToContext>true</AddToContext>
</CustomToolDef>
where rtfdiff.bat is
:: Use p4diff to get copy-pasteable diff output.
:: setlocal so we use the default after script terminates
setlocal
set P4DIFF=c:\Perforce\p4diff.exe
:: Diff all inputs to allow multiple revisions (must be in increasing order)
p4 diff %*
That will let you right click on a file and select "RTF Diff" or call rtfdiff.bat via command line (rtfdiff.bat file.txt#1 file.txt#2).

Related

Alternative to cmd and powershell for stdout output only

My use case:
I kick-off a Python script from a button within Excel to do some data aggregation. The setup currently works nicely, but I would like:
Cmd to never accidentally pause - it's a known feature of the command prompt to pause on any text selection: Avoid pausing tasks when select something on PowerShell and Command Prompt
To let the cmd prompt look more like a pop-up
I have noticed NSIS installers outputs it's commands in a little logging box:
Question:
I would like to know if there are any programs out there that does most of what I want already. E.g. something like RunLikePopup.exe c:\path\to\script.bat, with output like:
Not sure what you are really after. I 'll give it a try.
In case you build an application as 'console'-only than that results in a 'command-line-interface [CLI]' Look-and-feel. Plane and simple. The output of a NSIS script (.nsi file) can not be paused as it is simply the output of the compiler executing the script code. 'Pausing' that would instantly mean pausing the compiler to do its work. I see no reason why you would want that.
Example Unix 'more' command (sending text oriented content to stdout. CLI...)
https://en.wikipedia.org/wiki/More_(command)
In case you need to 'catch' the output from the NSIS compiler here is what you need to do:
run NSIS from (Windows) CLI:
makensis [ option | script.nsi | - ] [...] > compiler_log.txt
What you appear to want is typically named 'output redirect'. (https://ss64.com/nt/syntax-redirection.html). In case you need to 'catch' the outpout from a NSIS script at compile time, please use NSIS ' CLI and redirect the (compilers) output to any text file (e.g. compiler_output.txt)
PS. In order to ensure receiving good quality answers, try to be as specific as you can in your questions.
I have written a Freeware editor ME "Martins Editor" where you can send text via inpipe:
[C:\]dir /s | me in
"in" always shows the first page (does not scroll), "ins" scrolls and "inp" scrolls page by page. In this context, "me in" is a substitute for "more".
Then you will see the output in the editor. ME is a simple editor with the focus on multiplatform text (different EOL encodings, codepages). It has additional Wordstar ("IDE classic") key setting and HTML/XML highlightning. It is available for Windows, OS/2, Linux and MacOS.
http://www.hypermake.com/english/betatest.html#hd117
The 2016 version is still current. In the next weeks, I publish a new version.
I am working on a cmd.exe window replacement (commandline frontend) "MeShell" based on ME with look-and-feel of a normal commandline window. Because on the lack of a modern comfortable commandline window on the old OS/2 platform which is still alive (http://www.arcanoae.com), I will publish an OS/2 version first. If this version works fine, I will publish a Windows version later. In the context of MeShell, I improve the inpipe functionality of ME which is still buggy and does not support colors in the 2016 version.

Maintain VBS colors for HTA in Notepad++

I've got an HTA that uses a VBS script.
When I save the file as .hta though all the format coloring for my VBS script turns white.
Does anyone know a way to make it so NPP will recognize both languages and format the style coloring accordingly? It's nuts that the bulk of my script has no color formatting simply because it's wrapped in something else.
As a .HTA can contain more than one script language (even at the same time) and Notepad++'s syntax highlighting seems to be triggered by extension only (no special syntax switching markup; evidence), I would tend to associate .HTA with HTML and move all code to external files (src attribute of the script tag).
What I wouldn't do (to much work for little gain and risk of failure), is to experiment with combining the Style Configuration for HTML and VBS (Javascript/JScript, Perl, ...) into a new Style and associate that with .HTA.
Addition:
My prefered editor - Komodo (since 5.2) - allows to specify the 'language' for individual files; so I can switch syntax highlighting for mixed language sources on the fly.
Settings -> Style configurator -> Language:VB/VBS -> User Ext.: hta
The accepted answer misses some great options (I'm not sure if either or both were available with the same capabilities in 2014)...
Both the free text editor NotePad3 and the lifetime subscription IDE VBSEdit properly syntax highlight HTML, VBScript, and JScript in a single HTA file.

source file links in xcode console output

A lot of dev environments have some basic parsing logic applied to the output of programs while debugging such that if a program writes to the console (as a result of an error, assert) something like:
/Users/Foo/Project/SomeFile.m:12 - SOMETHING BAD HAPPENED HERE
the file path & line name are automatically detected as link to source, and one can click or double click on the text in question inside the console window to make the source editor jump here.
I have been trying to find out if XCode has something similar, but I haven't had much luck. Is any such functionality missing in XCode or am I just not finding the preferred text shape that it prefers?
Thanks
I just remembered "Open Quickly…". If you copy the text of the file name, then use the "Open Quickly…" function (Cmd-Shift-O by default), you can paste the filename in and press enter, and it will display the file.

Notepad++ : Custom Syntax Highlighting for .txt files

I keep code samples that I find useful as text files on my computer. I store them as txt files as opposed to the language in which they are written, so that they will open in Notepad++ instead of the editor (i.e. I don't want my c++ examples to open in an IDE, just Notepad).
Is there a way I can have Notepad++ apply appropriate syntax highlighting to the text file by reading a special code in the text file itself?
For example if I had some sql, the first line of the text file could read like this:
##Language=SQL
... my sql code properly highlighted as sql ...
Thanks in advance. I realize I could just choose the language after opening the file (i.e. Language > SQL), but it would be much more convenient if it could do it automatically.
No, it can't. You can choose it manually or use special file type extensions which you then associate with Notepad++ and tell it to highlight the files as the appropriate language.
For example, use .txtsql files for SQL, .txtcpp files for C++ and so on.
I ended up writing it myself:
You need the Python plugin
Add the code below to your startup.py file
Switch your Python Initialization setting from "LAZY" to "ATSTARTUP"
#if found determine the menu command and switch language in NPP
def switch_language_view(args):
notepad.activateBufferID(args["bufferID"])
lineone = editor.getLine(0)
if '##' in lineone:
lineone = lineone[lineone.rfind('##'):].replace('##', '')
lineone = "MENUCOMMAND." + lineone.upper()
try:
notepad.menuCommand( eval(lineone) )
except:
pass
#command to link notification
notepad.callback(switch_language_view, [NOTIFICATION.FILEOPENED])
I'd suggest giving them the proper file extensions, then import something like this into your registry:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\*\shell\NotepadPlusPlus]
[HKEY_CLASSES_ROOT\*\shell\NotepadPlusPlus\command]
#="C:\\path\\to\\notepad++.exe \"%1\""
Then you can open your files in NP++ with a quick right-click, and NP++ will be able to auto-detect the right language based on the file extension.
Manual selection is a much simpler way. Store all the files in .txt format (irrespective of java or C or C++). Open the file in Notepad++ and select the corresponding language in the Menu. e.g. Language --> Java.
You could try some npp scripting,
python
lua
and/or hacking macros. you could make the script start conditionally, check your special string and select the language for you.

Is there a Firefox add-on to use vim to edit textboxes?

or "How do I answer questions on SO in Firefox using gVim inside the textboxes?"
It's All Text!
From the extension page:
At the bottom right corner of any edit
box, a little edit button will appear.
Click it. If this is the first time
you've used "It's All Text!" then you
will be asked to set your preferences,
most importantly the editor.
The web page will pop up in your
selected editor. When you save it,
it'll refresh in the web page. Wait
for the magic yellow glow that means
that the radiation has taken effect!
Vimperator makes Firefox act very much like VIM:
Vimperator is a free browser add-on for Firefox, which makes it look and behave like the Vim text editor. It has similar key bindings, and you could call it a modal web browser, as key bindings differ according to which mode you are in.
Once you have the cursor in a text box, hit Ctrl-I to open in your editor, which defaults to gvim.
The current answers don't work anymore now that Mozilla removed XUL in favour of WebExtensions. With recent firefox versions, there are the following options (sorted in descending order by the current popularity on addons.mozilla.org).
GhostText provides instant synchronization between editor and textbox via editor-specific plugins. The project is on github and the vim extension is written in Tcl.
withExEditor is cross-platform but requires a native application written in node.js. In addition to editing text fields it also allows viewing the source of the page, MathML, SVG and the current selection. The project on github and the native node.js application
Textern requires a (currently) Linux-only native application written in Python. Synchronizes the content of the text field while you type in the editor. The extension and the native app can be found on github
Tridactyl is probably what you're looking for nowadays.
It's the spiritual successor to the likes of Pentadactyl and Vimperator, which are not available for the current version of Firefox.
If you want something more like It's All Text, where the editing area appears right on top of the browser text area rather than launching an editor window, and you're willing to use Neovim, check out firenvim.
It's All Text! will let you use whatever editor you want. To use vim with it, you'll need a small shell script to open it in a terminal:
#!/bin/sh
exec xterm -e /usr/bin/vim "$#"
If you have GVim, you won't need the shell, script, obviously.
ViewSourceWith is another addon worth lookng at. It supports more than just edit boxes and text. For example, you can configure it to open images in the GIMP.
Another feature that I find useful is that it can pop-up a dialog box that shows all the js and css scripts used on the page. You can then choose to view/edit file in your preferred editor.
For answering questions on SO, you may also want to get the Vim Markdown Syntax file
The "It's all Text" extension, perhaps?
http://addons.mozilla.org/en-US/firefox/addon/4125
If you use vimperator and have the markdown syntax file installed, a useful line for your .vimperatorrc is:
au LocationChange .* :set editor="gvim -f"
au LocationChange stackoverflow\.com :set editor="gvim -f -c 'set ft=mkd'"
This will tell vim to do syntax highlighting for markdown when you are on stackoverflow.com, but not when you are any other site. There are similar hacks for wikipedia/mediawiki etc. Enjoy :)
One way to do this is to use the vimperator extension - of course, that does a lot more than what you're looking for.
At the time of writing it is experimental, but the jV extension looks good. To quote from the page:
This extension makes all html textareas into a very stripped-down version of Vi[m]. It's modal, supports infinite undo, has register support, search, visual mode, and various movement and editing commands.
When using Vimperator in Windows (I am using Vista) you may need to double-escape the path to gvim.exe to use it as the external editor. Single escaping did not work for me as Vimperator unescapes it twice. Eg:
:set editor="C:\\\\Program\\ Files\\ (x86)\\\\Vim\\\\vim72\\\\gvim.exe" -f
Then while in a text box you use Ctrl+I and it will open gvim for editing. When you save and exit it will update the text box.
There is an experimental way to directly embed the real vim in firefox using embedded editor - though it requires mozplugger and will only work on Linux.
Try out the wasavi extension. You might want to check out the all versions page to make sure you try out the latest version. (Copy of this answer.)
You can also use the ViewSourceWith addon to achieve the same. Just right-click on any text input and you can edit it using Vim.
As said by others,
as a Vi/(g)Vim user you'll probably want to look at the Vimperator addon, which also provides the what you ask:
inside a textbox, hit <C-i> to launch the external editor.
(can be defined in _vimperatorrc: set editor=gvim -f )
A hint for Mac users: if you want to use "It's all text" with vim, the easiest way is to use http://code.google.com/p/macvim/ . Point "It's all text" to the mvim script that's provided along with the .app (you can place this script anywhere, I choose /usr/bin/ so that I can load mvim from the command line)
Pterosaur is a Firefox plugin that allows you to use Vim in all input fields. It uses an actual Vim process in the background so it has all the functionality you expect, including reading your .vimrc configuration and your plugins.
With Firefox-57 on Linux, I installed textern https://addons.mozilla.org/en-US/firefox/addon/textern/, and found it to be a suitable replacement for ViewSourceWith for editing text boxes.

Resources