Command-line options for HH and opening CHM Windows Help Files - windows

I'd like to be able to write Inquisit scripts in Vim.
In the standard Inquisit application for writing scripts, I can press F1 and it brings up help on the topic related to the word under the cursor.
I'd like to set up the same functionality through Vim.
The help file for Inquisit is stored in a Windows .CHM file.
I figured there must be a set of command-line options for doing a keyword search in a chm file, but I haven't been able to find a complete list of the command-line options, presumably for HH.exe.
I did find HTML Help command-line article from help-info.de with a few pointers, but it does not have a full listing of command-line options.
I also found this discussion on AutoHotKey discussion board. It mentions keyhh.
I also just found a vimscript designed to do exactly what I want
Questions:
Is there a complete list of command-line options for HH.exe?
Is there a better way of going about what I am trying to do?

If you can script in AutoHotkey ,I just found a solution. The idea will be to use VIM to pass reqd. command line-parameters to a compiled Ahk script which will in turn open the help file a/c the data.
In this solution, it will be also assumed that all the keywords that you are to search lie in the Index list (as they do).
To open the Helpfile, then Index tab & search, the following AHK Code works --
Run, %Helpfile% ; your help file
Winwaitactive, ahk_class HH Parent
SendMessage, 0x1330, 1,, SysTabControl321
sleep, 0
SendMessage, 0x130C, 1,, SysTabControl321
Send,+{Home}%1%{Enter}
where %1% is the only command line param passed to the compiled Ahk script.
So, VIM can passe Commandline params as start compiledahk.exe "<Keyword>".

Related

ksh - Display Current Mode

Is there any way to have ksh display the current typing mode at the bottom of the window like vim; like "Insert", "Command", "Visual", etc? Unfortunately, I am having a lot of trouble remembering which mode I'm in and find the shell unintuitive (at least until I get used to all the commands). I consistantly hit the wrong key in command mode and have difficulty figuring out how to get back to proper typing (sometimes it lets me type but not delete part of the line and I don't know why).
I am required to use ksh for work and am heavily restricted in what I can download and install, but I need to figure this out. Hopefully there is something I can do with a profile or script along these lines to help ease the transistion. Also, this is HP-Unix, in case that affects anything.
This set -o alone command will show if emacs is defined to on
$ set -o|grep emacs
emacs on

how do i make a batch program that types

hi i am interested in making a batch program that allows me to be able to place my cursor anywhere and have the batch program type for me as if i'm typing. i have looked at a lot of different sites for help but it might be it's impossible with batch programming or i just need someone on here to tell me how your input is much appreciated. i have tried to use echo >>etc .text commands but that only inserts input into that specific text document. I would like to know this because it would improve my batch programming and would be a valuable tool to have.
Ok, after a bit of thinking, the only way to do this is to update the clipboard with whatever you want to "type" into the program, and then press "Ctrl + V" to paste it. The way you would go about inmplementing this is up to you, but to place something in the clipboard via batch is:
Clip < file.txt
And you would have to make a batch file which would continuosly update the clipboard with whatever you wanted to paste. The way you do this is up to you.
Other then that, I dont see any other way you could do something like this in batch. Like I mentioned your better off doing this in C#.
Mona

How to step through an R script from the beginning?

I want to step through an R script. I saw the "debug" command while searching for how to do this but that seems to only apply to functions. This script doesn't have any functions.
The "browser" command looked promising so I put "browser()" as the first line of my script but it didn't seem to do anything when I ran it.
How do I get the script to pause on the first line so I can step through it?
I was racking my brain trying to figure this out (stepping through a script without a specific function to call) in RStudio's IDE Version 0.98.1102.
Solution for a new script in RStudio:
Create a new R script (ctrl+shift+n)
Enter code in the file
Set a break point by
a) clicking left of the code line number where you want to set a break point (red dot) or
b) adding browser() to the code line where you want to set a break point
Save the file
Enter debugging mode and source the file by
a) checking the Source on Save box (above the Source window) and then saving the file,
b) clicking the Source button at the top-right of the Source window,
c) entering debugSource("<yourfilename>") + enter in the Console, or
d) entering ctrl+shift+s
Go through the debugging process
For more steps on debugging in RStudio, see this help file
(dated April 23, 2015 12:59).
I'm partial to RStudio, so I recommend the following:
Download RStudio
Open your R Script
put your cursor on the first line
click ctrl + enter (PC/Linux) or command + return (Mac)
repeat!
A nice feature of RStudio is that RStudio server can run great on a headless server. You then connect to the server via http in a web browser on your local machine. I use this configuration when running R on EC2 instances. RStudio maintains state so if I lose internet access on my train ride, when I get signal back RStudio picks up exactly where I left off and my remote machine has no idea that I disconnected and reconnected. Note that RStudio server is currently only supported on FC/CentOS and Debian/Ubuntu. Although it may compile under other variants of *nix.
One popular way is to do this from your 'IDE' or editor -- Emacs / ESS do it very well, others do it too.
The basic idea is that you send either the line under the cursors, or function, or block, ... to the associated R process. Several other editors support this, including RStudio. My preference is still with ESS, but I am sure you can find something suitable.
Lastly, browser() et al can do that from within the R process but it is a little less pointy-clickety. Read the documentation, or books like Chambers "Software for Data Analysis" (Springer, 2008).
For an R only solution, which evaluates complete expressions rather than individual lines, try this:
sourcep <- function(file){
coms <- parse(file)
for (i in seq_along(coms)){
print(coms[[i]])
eval(coms[[i]],envir=.GlobalEnv)
mess <- paste("Expression",i,"of",length(coms),"parsed. Press <return> to continue.")
cat(mess)
readLines(n=1)
}
}
You call this as you would call source (though this is much more basic and doesn't include any of its options). Basically, it uses parse to create a list of the parsed, but unevaluated expressions from your source file, then iterates through this list to print the expression, evaluate it in the global environment and then put a message to indicate the progess. The final line is the one that creates the pausing: a call to read a single line from stdin().
You mention in a comment that you run your code with Rscript, but to debug you need to run it interactively. In other words, to get browser to "work", start up a regular R console and source your script. Since the first line of the script is browser(), you'll immediately get back to the prompt, at which you can use "n" to single step through the code. But, since it's a full-blown R prompt, you can also check or change any variable value just by typing its name or assigning to it. (Or indeed, invoke arbitrary R functions.)
As suggested in another answer, inserting browser() at the beginning of your script, getting an interactive session by running R rather than Rscript, and then using source('myscript.Rscript') from R will do the trick if your script does not require commadline arguments (e.g. like those processed by argparse).
If you do need to run with commandline args, you can simply invoke R with the --args options (e.g. R --no-restore --no-save --args <your commandline args here>) and the sourced script will see the arguments as if it had been invoked using Rscript. There are other solutions to the question of how to pass commandline args to source, but they don't target this specific use case where source will be called only once.

What can I do in VIM that I can't already do in Visual Studio? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I heard it takes 30 days minimum to get comfortable with vi. I'm on day 2 hehe. Right now, I seem to be merely memorizing different shortcuts for things I already did in Visual Studio (incremental search, prev/next word, etc.).
So far the most powerful aspect seems to be the numeric keys combined with commands (5 * next line), and the idea of normal/insert modes.
There are a few things I miss from Visual Studio. Ctrl-Click'ing the mouse for quick copy and pasting is probably the biggest.
So that I don't get discouraged, can you guys walk me through some things in vi that you do regularly that can't be done in Visual Studio? It'll help me focus on what to learn and help me develop better habits.
I'll just leave a link to this SO answer here.
VI means never ever having to take you fingers off the keyboard.
Note that I don't use Visual Studio, and know little about the available features in it. The following are examples of what I find useful in Vim, not a list of missing features in Visual Studio.
Macros
It's easy to create macros for complex (but repetitive) operations. To illustrate with a simple example, let's say we start with:
Line1
Line2
Line3
Line4
Line5
Now we want to envelop each line in a print(""); statement.
Place the cursor on the first line, and enter:
qx to start recording a macro to the register x
Shift+I print(" Esc to insert text at the beginning of the line
Shift+A "); Esc to append text at the end of the line
j to go down one line
q to stop recording the macro
4#x to execute the macro in register x 4 times
See :help complex-repeat for more info on Vim macros.
Text objects
Note that this is one of the improvements Vim has over the traditional Vi. If it doesn't work, you're probably running in Vi compatibility mode; use :set nocompatible to enable the full functionality of Vim.
Text objects allow you to easily select regions of text. Let's say we start with the following text, and place the cursor on some text:
<b><i>some text</i></b>
Now we want to delete everything between <i> and </i>. This can be done by simply typing the command dit (d'elete i'nner t'ag)! Or if we want to include the tags themselves in our selection, use dat (d'elete a t'ag). To delete everything inside the <b> tags, use d2it (d'elete two i'nner t'ags).
You can similarly use daw (delete a word), dap (delete a paragraph), di" (delete inside double-quotes), etc; see :help text-objects for the complete list.
Another useful example of text objects:
v2ap"+y
v toggles visual mode. This makes it easier to see what you're selecting, and lets you adjust your selection with a series of multiple motions before you execute a command.
2ap selects this paragraph and the next one
"+ selects the system clipboard as register for the next operation
y yanks the selection to the given register
In other words, that command would copy two paragraphs from your text to the system clipboard (e.g. for pasting them here at StackOverflow).
Global editing
The global command is used to apply an Ex command to all lines matching a given regular expression. Examples:
:global/test/print or :g/test/p would print all lines containing the phrase test
:global/test/delete or :g/test/d would delete said lines
:global/test/substitute/^/#/ or :g/test/s/^/#/ would search for lines containing the phrase test, and comment them out by substituting the regexp anchor ^ (beginning-of-line) with the symbol #.
You can also do some cool stuff by passing the search motions /pattern or ?pattern as ranges:
:?test?move . searches backwards for a line containing test, and moves it to your current position in the file
:/test/copy . searches forwards for a line containing test, and copies it to the current position in the file
Good luck and have fun learning Vim!
Edit a file on a Solaris machine that only allows SSH access.
This article is what got me started on Vim, and I never looked back:
http://www.viemu.com/a-why-vi-vim.html
It has some great examples on Vim's power.
Use screen to keep a session running on a remote machine accessed over ssh
Visual Studio's regular expressions are a little bit Mickey Mouse. Vim has the full POSIX regular expression language at your fingertips.
As far as I can tell (in Visual C# express 2010) ctrl-click just selects whatever word you click on. To do the same in VIM, you can combine the yank command with a movement command.
So you press "y" for yank (copy) then "e" or "w" to copy to the end of the word.
There is many differences.
Block (and column) wise copy, paste, edit
the dot command! (after duck tape the second most powerful tool on the planet, seriously)
I suggest you watch some screencasts at http://vimcasts.org/ to get a feeling of the power of vim.
e.g.:
http://vimcasts.org/episodes/creating-the-vimcasts-logo-as-ascii-art/
http://vimcasts.org/episodes/selecting-columns-with-visual-block-mode/
You could always use the Vim emulator/add-on for Visual Studio and get some of the power of vim mixed with the features of VS. If you're already using Visual Studio, I assume you're using a .NET language, which without VS, would be much more painful to use.
Vim Essentials is a nice set of slides.
Personally, I got used to vi a long time ago, when we didn't have the luxury of a mouse in student's Unix terminals. Since then, I used vi/vim for everything safe for writing emails.
To this day, I probably use only 1/20 of the commands, but never felt the need to write code with another text editor, and reaching for a mouse in an IDE feels very clumsy to me.
Using high level and expressive languages, that do not require an IDE (mainly python, sql, javascript) really helps. I suppose it wouldn't be as easy with Java or C++.
Not having to move and point with the mouse when coding (safe for using the browser) also helps preventing Carpal tunnel syndrome.
BTW, I suppose Vim integrates better with Unix than with Windows... and who said 30 minutes was a little optimistic :)
Edit documents over SSH. Vim's really nice for that.
Edit: looks like a lot of people have already said that :)
teco is your answer. You only need a PDP-10 and an ASR-33 and you're on your way!

General Purpose Filter As You Type (aka typeahead, Incremental find, autocomplete) is it out there?

Background
Lately I've become a fanatic that everything I type while working on a computer should be compatible with "DRY". If there's anything I have to type more than once in any context, I want some kind of user-aware auto-complete option to do some of the work for me -- always -- no exceptions.
Having to work under Windows, I've looked at GUI solutions to make this insane goal a reality.
The (almost) optimal solution
If you have a moment, open up Firefox 3.0 and type a few keystrokes into the address bar. You will notice that it performs a kind of Incremental Autocomplete based on space-separated sub-strings of whatever you type. Another place in Firefox that does something similar is the about:config URL.
This is sub-optimal, because I don't want this in Firefox only. I want to use this everywhere.
The Question
Does anyone out there know of a widget or app that does nothing but insanely good incremental auto-complete that can be used as a general purpose "run everywhere" tool? Something that allows the user to: 1) maintain one or more "completion candidate files"; 2) pick one of those files as the source for Firefox 3.0 style completion; 3) return the result (or blank if the user canceled), and do those three things only?
Details
Here's how it should work:
STEP1: user saves or more csv file(s) (or other easy-edit format) somewhere in his hard-drive
STEP2: user creates a Windows Script Host script or a batch file (or whatever) instantiates the FilterAsYouType GUI
STEP3: user runs the script file, and the script file instantiates the GUI, telling it which CSV file to use as the source of all potential completions
STEP4: the user either chooses one of the completions, supplies his own text that is not in the list, or cancels out without supplying anything
STEP5: when the user is done the script saves the result to a variable and does something with it
Here is some pseudo-code for the script:
include "GenericTypeaheadWidget";
var gengui = new GenericTypaheadWidget('c:\docs\favorite_foods.csv');
var fave_food = gengui.get_user_input();
if(fave_food != ''){
alert('you chose '+fave_food+'!');
}
The rationale
The goal is to just have a way to always be able to do auto-completions from a list of arbitrary items, even if the list is a couple thousand items, and not have to rely on it being built into some IDE or standalone application that only accepts certain kinds of input or has an overly-complicated API relative to the simplicity of this task.
CSV (or text or sqlite database) would provide a way for me to self-generate "candidate lists" or "history logs" and then just use those logs as the source of the possible completions.
The disclaimer
I've tried several GUI "launcher" programs, command-line engines like power-shell and scripting shells, the regular plain old command-line history with varying degrees of satisfaction. The problem with these is they all do extra superfluous stuff like searching directories or built-in commands. I just want nothing but whatever is in the CSV file I happen to be pointing at.
I'm wondering if there is any simple tool that does nothing but what I'm describing above.
UPDATE: It looks like this question is very closely related to Graphical Command Shell, which captures the essential idea presented here.
You should really try Launchy - it's exactly what you're looking for, a "run anything" with intelligent autocompletion. It completely changes the way you interact with a Windows PC.
And it has open source-code, so you can borrow its autocompletion code if you want to roll your own interface.

Resources