On Tue, Jun 27, 2006 at 03:56:22PM -0400, Dimitriy V. Masterov wrote:
> Thank you very much for your suggestion. I'm still having trouble
> yanking the highlighted text instead of the line the cursor was on.
>
> I was able to do something like this in jEdit using
> textArea.getSelectedText(). Is there something analogous for Vim?
>
> My jEdit code is here:
>
> rundolines() {
> // Copy selected text
> String text = textArea.getSelectedText();
>
> // Create a temp file
> File temp = File.createTempFile("dofilelines", ".do");
>
> // Delete temp file when program exits.
> temp.deleteOnExit();
>
> // Write to temp file
> BufferedWriter out = new BufferedWriter(new FileWriter(temp));
> out.write(text);
> out.close();
>
> // Run the temporary file in Stata
> String command="C:\\Program Files\\Scripts\\rundo.exe " + "\"" +
> temp + "\"";
> exec(command);
> }
>
> rundolines();
Are you having trouble yanking the text "manually" or from a
script? If you are in Visual mode, then change to Command-Line mode to
execute a :command or a Function(), then you have to get back into
Visual mode in order to yank the text you want. Based on your jEdit
code above, I am guessing you want something like this:
fun! Rundolines()
" Copy Visual text into register a
normal! gv"ay
let temp = tempname() . ".do"
execute "split" temp
" or :edit or :tabedit instead of :split
put a
let command = ...
execute command
" I assume we are still editing the temp file now.
q!
endfun
Most users seem to forget that :execute can take more than one argument.
Thus my first :execute line should do the same as
execute "split " . temp
Disclaimer: the entire function is untested. (Just in case it is not
clear that the last :let line is incomplete.)
HTH --Benji Fisher