Maintain VBS colors for HTA in Notepad++ - vbscript

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.

Related

Make Notepad ++ highlight matching if/fi tags

Notepad++ is generally great about highlighting matching tags. However, in shell scripts, it doesn't highlight if/fi (or case/esac). Is there any way to make it do that?
I'm using the Je sui Charlie edition, it's a bit older, but under the language tab I see no language profile for bash shell. You might need to make your own syntax highlighting profile using the
Language -> Define your language...
menu option. It's not very hard -- I've made custom profiles for Gcode, Gerber files, and others.
There's a great kickstarter for this task here.

ActivePerl. .pl files no longer execute but open in Notepad instead

I have perl scripts which were running in Windows 7 just fine as of this morning. I made the mistake of using NotePad as the default for opening/editng my .pl files. Now, when I attempt to run the unedited .pl files from a DOS prompt, the script does not execute but opens the associated source code file in Windows Explorer. This is the same for all my .pl files no matter the complexity (including classic "hello world".
I have been researching changes need to the registry - it all looks fine. Tried assoc and ftype changes - nothing. Tried reinstalling ActivePerl - no solution.
You don't need to go into the Registry.
Go into Windows Explorer.
Find a file that ends in a *.pl suffix.
Right click on it and bring up the Context menu.
Select "Open With" (It might just be Open... with an ellipse after it. I don't have a Windows machine at the moment to verify this). This will bring up a dialog box with all the various programs. NOTE: Perl may not be listed in the initial set of programs. No worry, just navigate to it.
On the bottom of the dialog box is a checkbox (Something like open all extensions with this program). Make sure that checkbox is checked.
After this, all files that end with *.pl will open with Perl instead of Notepad.
It is highly likely that someone did this with a Perl script in order to edit it, and messed up the file association.
However, who ever did this should be doped slap -- not for messing up the file association, but for editing a program with Notepad. Bad Developer! No doughnuts for you!
Programs should be opened with a Program Editor. If you're a real he-man, you can use VIM. VIM is a fast, and powerful program editor, but you will need to spend an internship at the feet of a VIM Ninja master in order to learn how to use it. Your first three to six months with VIM will be What a idiotic program! This is awful. Who wrote this crap?. Then, one day, you will understand its power and efficiency. You will be one with the program.
If you aren't brave or fearless or don't have six months to waste learning a programming editor, you can use Notepad++. Compared to VIM Notepad++ is like driving a Minivan. It's safe, it's practical, and it gets the job done.
Both editors do Syntax Highlighting which can help you find issues. Both, (VIM can -- I think Notepad++ can too) offer help with syntax and usage. Both can edit a file without messing up the line endings (They'll both detect whether a file has Unix or Windows line endings and keep those or allow you to convert them). Both will number your lines, have extensive cut/paste buffers, powerful search and replace features. And will not mess up your file encoding. Both offer visual diffing between files and do automatic backups when you edit a file.
Finally, these two editors will embed themselves into the context menu you get when you right click on a file. You can edit a file by clicking on it, and selecting VIM or Notepad++ directly from the context menu. No need to select "Open with..." and possibly mess up the file suffix association.
Never ever use Notepad to edit a program.
Sounds like your .pl extention association is now set to Notepad rather than perl.exe. If you are too busy to fix that, just type "perl yourscript.pl" in a command promot window to start the perl interpreter and to send your script to it to run.
See this answer to fix the association:
File Type .pl Association and Using cmd.exe to Run the Script
I have the same problem. None of the method mentioned above solve the problem. The problem actually came from Windows 7! Windows 7 Doesn't allow you to associate .pl to perl.exe in c:\Perl64 directory, for whatever reason.
Here is the solution:
If you look at c:\Perl64\Bin directory (or the path where your ActivePerl binary installed), you'll see another file: Perl5.14.2.exe. This is the same file as perl.exe in same directory but with version number attached as postfix in the name.
You can associate .pl file to that Perl5.14.2.exe instead of perl.exe. Bingo, it works now.

Windows Macro + Hot Key - Paste Without Formatting

Not sure if this appropriate to put as a question or not? It's sort of a scripting question I think. Just down vote me if not :p
Basically, what I'm looking for is a way to push a windows hotkey and have whatever text is in the clipboard be stripped of formatting. An example of what the macro could do:
I push (whatever hotkey combo here)
open notepad.exe
Paste to notepad from clipboard
Select all text in notepad
Copy/Cut all text from notepad
Close notepad
I'm just wondering if someone has done something like this before, or knows how it could be accomplished. I think this could be a huge time-saver for almost anyone. I find myself doing this all the time when cutting and pasting between different office applications, etc.
Have you heard of Puretext, it appears to do what you're looking for:
http://www.stevemiller.net/puretext/
Instead of emulating hotkeys to control Notepad, you can write code to implement what Notepad implements when it gets text from the clipboard: i.e. use the clipboard API to get the clipboard contents as unformatted text.
Try AutoHotKey to make a tiny and easy script to do what you want.
You will find a powerful windows interface macro programing tool.

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.

Pasting diff output into Microsoft Outlook with syntax highlighting

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).

Resources