Vim
Install vim
You will probably need to install vim
sudo apt-get install vim
Is an excellent choice for linux and mac users, it is lighweight (runs from the console) commands available from vim:-
:!jruby % # will run the sketch
Live coding with Pry
jgem install pry
# or jruby -S gem install pry
# or if you must use rvm or rbenv not recommended
Do echo "Pry.config.editor = 'vim'" > ~/.pryrc
to set vim as the pry editor.
Fire up pry using
jruby -e "require 'pry'; binding.pry"
Or more conveniently create a shortcut by using jpry
alias in your .bashrc
or equivalent eg .profile
debian linux:-
alias jpry="jruby -e \"require 'pry'; binding.pry\""
At the pry prompt:-
load 'my_sketch'
Creating my_sketch
is a easy as picrate -c my_sketch 300 300
To get full listing of sketch in pry enter $
at the prompt, to edit the draw
method at the prompt do:-
edit -p MySketch#draw
On finished save and quit :wq
(or :wqa
to save all changed buffers) sketch will redraw reflecting changes, but you can repeat:-
edit -p MySketch#draw
this allows you to edit your changes which are saved in a .tmp
file. Read more about vim / emacs integration here
Other advantages of vim
Also because vim is run from the console it is so easy to run old friends like rubocop
or reek
on your sketch code.
If you are millenial and allergic to the command line install use an editor that supports ruby syntax, emacs is only for hardcore geeks. As yet I don’t think the raspberrypi supports atom
as an editor.