Re: [chuck-users] chuck shell... --> My vim usage
From: kurt
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
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
From: kurt
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@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
Additionally take a look here: http://tasmo.de/chuck.htm
Cheers
On Fri, Sep 11, 2009 at 4:06 AM, Cody Loyd
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
wrote: From: kurt
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@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
_______________________________________________ chuck-users mailing list chuck-users@lists.cs.princeton.edu https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
participants (3)
-
Bill Nye
-
Cody Loyd
-
Thomas Friese