[chuck-users] chuck shell... --> My vim usage

Cody Loyd codyloyd at gmail.com
Thu Sep 10 22:06:18 EDT 2009


VIM can execute bash commands.. so from vim you can control chuck
using the familiar command line controls like this:

:! chuck + %

in this command :! tells vim to do a bash command and the % refers to
the currently opened file.  I have bound this and similar commands (
remove shred and replace shred) to keyboard shortcuts.

not saying that doing this is better than what you are doing... just
another option.

(vim is awesome!)

On Thu, Sep 10, 2009 at 7:47 PM, Bill Nye <nye2 at email.com> wrote:
>> From: kurt <sobrilliant at gmail.com>
>> I like the Mini but I really like Vim. That is
>> really the only reason I use the shell.
>
> When I heard mention of vim I thought I would
> share what I use to test chuck code snippets,
> directly from inside vim.  To get alignment, be
> sure to view the following with a fixed-width font.
>
> It consists of one bash script, a symbolic link,
> and, on Win, a .bat file.
>
> In the main bash script below, the second 'cat' line
> returns the same stdin chuck code lines back into
> vim, followed then by chuck's stdout.  (Of course,
> you also hear the chuck output, if any.)
>
> I'm sorry to say that after days of trying, I could
> not get chuck to play, and also deliver its stdout
> in just one invocation, hence the two chuck.exe lines.
>
> FILE ~/bin/chuck_execution_in_vi  (Win version)
>  #! /bin/bash
>  # chuck_execution_in_vi -- Typically used in vi as:
>  #   :'a,.!chu  to leave original lines and also
>  #              return Chuck execution output.
>  tmp="/tmp/tmp.chu.ck.$$"
>  cat > $tmp
>  cat   $tmp
>  cmd /c start "`cygpath -w ~/bin/chuck.exe`"          $tmp
>               "`cygpath -w ~/bin/chuck.exe`" --silent $tmp  \
>      2>&1 | tr -d '\015'
>  rm -f $tmp
>  exit
>  TESTS:
>    Sit on next line in vim and type   :.!chu
>    <<< "Hello" >>>;
>    You should see in vim after the '<<<' code line:
>      "Hello" : (string)
>    Sit on 'now' line and type   :-,.!chu
>    SinOsc s  => dac;
>    1::second => now;
>
> FILE ~/bin/chuck_execution_in_vi  (Mac version)
>  #! /bin/bash
>  # chuck_execution_in_vi
>  tmp="/tmp/tmp.chu.ck.$$"
>  cat > $tmp
>  cat   $tmp
>  chuck $tmp  2>&1
>  rm -f $tmp
>
> On Mac and Win (cygwin) I have this symbolic link
> to cut down on typing:
>  ~/bin/chu -> ~/bin/chuck_execution_in_vi
>
> On Win, I also need this parallel .bat file:
> (I set the 2 env vars in my .profile)
>
> FILE ~/bin/chu.bat
>  @ECHO OFF
>  PATH %WPROGRAMS%\cygwin\bin;%PATH%
>  %WPROGRAMS%\cygwin\bin\bash  %WHOME%\bin\chu  %1 %2 %3 %4 %5 %6 %7
> %8 %9
>
> Of course, this only works well if the chuck code
> terminates on its own.  I don't know what this can
> do for --loop or shreds but it may give you some
> ideas.
>
> Incidentally, on both Mac and Win I have QuicKeys,
> so I just do 'ma' (to mark the snippet beginning)
> move to the end, and type Ctrl-Shift-C , which simply
> types :'a,.!chu  for me.       -Bill
>
> _______________________________________________
> chuck-users mailing list
> chuck-users at lists.cs.princeton.edu
> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
>


More information about the chuck-users mailing list