Notepad++: Writing a run command using an installed plugin - plugins

I am trying to find a way to take the syntax highlighted text from N++ and then open it within say MS Word. I have found the plugin NppExport which can save the highlighted text to a rtf file. But it seems N++'s macros are not able to really utilize it. Any suggestions to automate this process? Thanks!
Basic steps are
1) call "Export to RTF"
2) Save to ${FULL_PATH_NAME}.RTF
3) open the RTF file
3) Open MS word
Note: I have 4 figured out using
"C:\Program Files\Microsoft Office\Office12\Winword.exe" /f "$(FULL_CURRENT_PATH)"

Since you are meshing two programs (Notepad++ and Word). It may be difficult to do totally in the macros. I haven't had much luck with the macros beyond repetitive text manipulation. But I can recommend the tool AutoHotKey (autohotkey.com) which makes implementing these tasks super simple. Here is a little example that I tried out. Yes it works.
^#R::
WinMenuSelectItem , ahk_class Notepad++,,Plugins, NppExport, Copy RTF to clipboard
SetTitleMatchMode, 2 ;find by partial title
WinActivate Microsoft Word
Send ^v
This will copy the text in RTF switch the active window to word and paste the code. It would be relatively simple to change the command to open a new window instead.

Related

AHK Sending a TXT file as typed out text

am using AHK to publish boilerplate e-mail body texts in our company. Our employees use various webmail, and other mail so managing templates is impossible. So comes AHK. We have created scripts to publish this with the details of the boilerplate within the body of the script, but it is difficult to delegate revision management when the script itself needs to be edited each time as the boilerplate text changes. Is there a way to send the contents of a Text file, i.e. "bp..pins.txt" as a keyboard input verses placing all the boilerplate text within the script?
Btw: We use Dropbox to sync scripts across users computers.
One way to do that is to simply use the command FileRead
FileSelectFile, path
::doit:: ; hotstring type "doit" to activate
FileRead, FileContent, %path%
Sendinput %FileContent%
return
Hope it helps
Do realize that SendInput has limitations. If you send enough text, it will buffer in the keyboard buffer and show up on the screen much slower than expected. It won't take more than a paragraph for the SendInput to end up being slower than a manual cut and paste.
I recommend reading the file into the clipboard and pasting it instead:
FileSelectFile, path
::doit:: ; hotstring type "doit" to activate
FileRead, FileContent, %path%
Clipboard := FileContent
SendInput ^v
return

Using vim as default editor for matlab

I want to use gvim as the standard editor for Matlab. It used to work on Linux but now I am forced to use windows and I can't seem to figure out how to set the editor such that files are opened in gvim in a new tab.
In the preferences there is a field which allows to pass a command that points to the prefered text editor. That works, but things fail when I try to give additional options, in my case that would be "--remote-tab-silent" to tell gvim to open the file in a running instance in a new tab. More specifically, the following line in the matlab preferences works:
C:\pathtovim\gvim.exe
while this one fails
C:\pathtovim\gvim.exe --remote-tab-silent
A command line opens with the following error message (my own translation from German):
The command ""C:\pathtovim\gvim.exe --remote-tab-silent"" is either spelled incorrectly or could not be found.
My guess is that it has something to do with the additional quotes, I have no idea why the command is issued with quotes, even though in the field I put it without. The follwing commands work when typed into the command line directly:
"C:\pathtovim\gvim.exe"
C:\pathtovim\gvim.exe --remote-tab-silent file.m
and this one fails:
"C:\pathtovim\gvim.exe --remote-tab-silent file.m"
I'd really appreciate any help! Thanks!
I can't find a good way to hack around it through the MATLAB settings; it looks like MATLAB is stupidly expecting the text editor to take only file names as arguments.
I think your best option, is to create a .bat script that simply passes any arguments it receives on to Vim, inserting the --remote-tab-silent.
I.e. create a .bat file with these contents:
"C:\pathtovim\gvim.exe" --remote-tab-silent %*
Then set up your MATLAB preferences to invoke the .bat file rather than Vim.

Multiline CoffeeScript REPL in Sublime Text 2

I want to be able to send entire files and selections to the SublimeREPL and eval them, but it doesn't work. CoffeeScript REPL will only read one line at a time.
Coffee will only take single lines, until you use ctrl+v to switch CoffeeScript to multiline (which works in Terminal), but is blocked by sublime's interface... I'd really like to be able to eval more than one line using SublimeREPL's "ctrl+, s", "ctrl+, f" key bindings. There seems to be no direct way to open coffee with multiline mode automatically.
Maybe I'm going about this wrong, but it's only reasonable that I could use multiline JS Object notation in a CoffeeScript file, for example, and then test it in the REPL. I do it in Python and straight up Node all the time.
You need to be able to switch multi-line on then off again, so ideally if I could edit Sublime REPL to run that key shortcut ( ctrl+v ) before and after running a snippet of code that would be the best.
SublimeREPL v2.0.9 will fix your problem using multiline hack in repl.coffee.
[Ctrl+, s] and [ctrl+, f] should work as expected now :)
Release notes: https://github.com/wuub/SublimeREPL/releases/tag/2.0.9
repl.coffee http://coffeescript.org/documentation/docs/repl.html#section-2
I made a plugin: https://github.com/billymoon/Sublime-Pipe-Dream/ which aims to do this - and much much more. It needs patching up a bit - so any help appreciated. I use it on my mac with sublime text 2 to pass arbitrary selected text, or whole buffers (not saved files) to shell commands and either display the result in the console, or replace the selected text with the console output.
This is very handy for converting coffee to js, js to coffee, executing js/coffee/sql, beautifying and uglifying code and anything else where you want to pass text through a command line script.

Printing a Project in NetBeans

I have an exam and I would like to print my Java (in NetBeans project) files as fast as possible. I was wondering is there a way to print an entire project/project in NetBeans with one click? or do you have a better suggestion? (I will be using Windows XP and there is no nice editor like Gedit or Kate installed)
Give that the identical question on the netbeans forum from last year is not answered yet, I would say no.
When I needed to print off my final year Comp Sc project (needed to hand in a full print out + polished install CD, oh the poor trees that died for that one...), I opened every file then went through and did a print & close on each one. :(
It can be done. Switch to file mode, select all files, open all, then print. From http://dgreen.github.io/blog/2010/11/02/printing-multiple-files-in-netbeans/
I had the same problem. I am in a Computer Science class with Java Programming. My homework asignment involves creating a project with many class files (7 at the moment) so I searched google for how to print out the project and found nothing. However, I have come up with a bit of a kludgy way to do this, after reading it you can be the judge of how much time it will actually save. The more classes you have in a single project, the more time it will save. The methodology is kludgy because it involves as little system access as possible, because as you said you are on a school computer so I will assume only the most basic access. It DOES require command prompt access, so this may not be helpful for you. However, it is possible that if you cannot open the command prompt you may be able to execute a .bat file. So here goes.
Point command prompt to your source directory and type:
dir /b > projectDir.txt
or save that 1 line in a text editor as dir.bat
this will give you a text file listing all of the java files in your source directory
open notepad and type this 1 line
/*PAGEBREAK*/
save that file as pagebreak.txt
now, open the projectDir.txt file you created with Notepad.
do a global replace of ".java" with ".java+pagebreak.txt+"
get rid of the line that has projectDir.txt listed
save the file as projectDir.html
open this file in a web browser. the point of this is to get rid of the line breaks created by using dir /b.
now, copy this line of text and paste it into a new notepad window. at the beginning of the line, add "copy /b " and at the end of the line, replace the final "+" with " wholeProject.java"
run your bat file. if everything has been successful, you will have a single java file containing all of your classes. add this file to your project tree in netBeans IDE.
Export that file as an HTML file. one problem is that if you use line numbers, the numbers will be continuous; each new class will not start with 1, so I would advise against that.
Open up the html file in notepad. Do a global replace of "/*PAGEBREAK*/" with "<p style='page-break-before: always'>". Save your file, open it in a browser.
When you print it, it should print each class on its own page.
hope this helps! netBeans should really implement this though, my method is pretty goofy and contrived.
I found a new way (I hope it is a new way...)
You first want to copy the html , you can do that by choosing "Print to HTML ... " option from the Netbeans settings and choose the " Print to Clipboard " option .
Open the any text app and paste it , save with .html extension .
Now you can use from any browser to print the way you want it .

Recommendations for developing Sweave documents

I'm looking to streamline my Sweave document creation, and I'd like to hear about people's current setups. I feel like the holy grail goes something like this:
Editing Rnw code on one half of the
screen
Single keybinding compiles
Sweave document and runs pdflatex
View PDF
on the other half of the screen; once
compiled, PDF is refreshed and centered around the portion of the document you're editing
If compilation has errors, replace the PDF with the results of the compilation (e.g. latex errors or Sweave errors)
I am guessing/hoping that the solution is part Emacs/ESS combined with some code for the Emacs profile and/or a nice Makefile. But I would really like to hear about everybody's preferred way of creating Sweave and/or Latex documents.
A few other R users I talked to use a 'one-directory-per-project' setup, and a simple Makefile. As you suspected, that works well with Emacs/ESS.
I tend to just call a simple shell script sweave which I wrote before before 'R CMD Sweave' was added (as I find re-creating or copying the Makefile unappealing, YMMV). I also use Emacs and an auto-refreshing pdf viewer (like okular or kpdf). Emacs23 can preview pdf files directly too but I have yet to switch my work flow to that.
edd#ron:~$ cat bin/sweave
#!/bin/bash -e
function errorexit () {
echo "Error: $1"
exit 1
}
function filetest () {
if [ ! -f $1 ]; then
errorexit "File $1 not found"
fi
return 0
}
if [ "$#" -lt 1 ]; then
errorexit "Need to specify argument file"
fi
BASENAME=$(basename $1 .Rnw)
RNWFILE=$BASENAME.Rnw
filetest $RNWFILE
echo "library(tools); Sweave(\"$RNWFILE\")" \
| R --no-save --no-restore --slave
LATEXFILE=$BASENAME.tex
filetest $LATEXFILE && pdflatex $LATEXFILE
You can do everything that you suggest there with the StatET plugin for Eclipse. That's what I use for Sweave development; it understands both latex and R very well, including syntax highlighting, etc.
You can get it here: http://www.walware.de/goto/statet.
Longhow Lam has written a nice guide: http://www.splusbook.com/Rintro/R_Eclipse_StatET.pdf.
http://www.statalgo.com/?p=93
I use TeXShop on OS X to produce all of my LaTeX and Sweave reports. For me, a new compilation pipeline is as simple as adding a file, called Sweave.engine to ~/Library/TeXShop/Engines/ which contains the following:
#!/usr/bin/env Rscript
args <- commandArgs(T)
fname <- strsplit(args[1],'\\.')[[1]][2]
Sweave(paste(fname,'Rnw',sep='.'))
system(paste('pdflatex',paste(fname,'tex',sep='.')))
Sweave is now a selectable method of compiling a document inside TeXShop. I can set it to be the default for a document by adding the following TeX hash-bang to the top of the file:
% !TEX TS-program = Sweave
Hitting Cmd-T will typeset the document- the pdf automatically pops up in a separate window. TeXShop also incorporates SyncTeX technology so a Cmd-Click in the Rnw source will highlight the corresponding output in the PDF window and a Cmd-Click in the PDF window will highlight the corresponding input in the Rnw source.
TeXShop is mac-only but a great Qt/poppler-based clone, TeXworks, is available for Linux, Windows and Mac and supports many of the same features-- including TeX hash-bangs and SyncTeX. TeXworks has reached a level of maturity where it is included in version 2.8 of the MikTeX package for Windows.
Try RStudio.
I have been a fan of Emacs and TeXShop as mentioned in previous answers.
However, Rstudio is starting to win me over. It is a rapidly-improving dedicated IDE for R. Definitely worth checking out.
I still love doing certain R-only development tasks in the standard R IDE for mac. But for Sweave documents and some associated R devel at the same time, RStudio wins. It works with virtually zero tweaking. I'm not sure about the PDF-related features in the latter half of the original question.
One thing that has saved me some time is the 'auto-insert' mode in emacs. I have it set up so that each time I open a new .rnw file, emacs automatically sets up a basic document template and all I need to do is start writing my report.
Update: I've switched away from auto-insert. Now I use the "template.el" approach.
I use the "one-directory-per-project" and Makefile approach as well. I also include commands to create output in HTML, which can then be converted to OOo and MS Word, using tth. This is important for me since a lot of my collaborators are MS Office users and are resistant to using the PDF output. I learned a lot about how to do this from Frank Harrell's twiki at Vanderbilt.
Personally I use gvim as my editor of choice and running make from there is quite simple, as it is from Emacs.