Skip to content

Cream Text Editor

7 messages · Paul Heinrich Dietrich, Jo Frabetti, Jakson A. Aquino

#
I'm interested in easing my way into learning VIM by first using the Cream
text editor, liking the idea that it will work on both my Linux and Windows
computers.  I've installed Cream on my Linux machine, but can't figure out
how to make Cream talk to R?  Does anybody know?  I'm using Ubuntu if it
makes a difference.  Thanks.
#
On 2009-May-23 , at 17:40 , Paul Heinrich Dietrich wrote:

            
You should install the R Vim Plugin and its dependencies:
	http://www.vim.org/scripts/script.php?script_id=2628
This creates commands and icons dedicated to the interaction between  
Vim and R.


Then switch cream Settings > Preferences > Expert Mode.

This will allow you to work in Cream and have all the simple keyboard  
shortcuts (Control-C, Control-V etc.) but still be able to switch  
between modes as in vim. By default you are in insert mode. You need  
to switch to normal mode (by pressing ESC) to be able to use the  
commands of the R-Vim plugin.

The workflow is therefore:
- open a R file
- edit stuff
- press ESC (to switch to non-edit mode)
- start R in a terminal (click the icon or press F2)
- send lines/selection (F9) or document (F5)
- press ESC (to switch back to insert mode)
- edit 2 lines
- ESC
- F9
- F9
- ESC
- edit again
etc...

The terminal opened this way does not work completely as a regular one  
and there are some caveats when reading help and using general command  
line editing shortcuts (Ctrl-R for backward search for example). I  
haven't found a way around them so I usually open a second terminal to  
read the help in, or set R to display the help as HTML files in a  
browser window.

I must say that those caveats can be quite serious and I often find  
myself just using copy-paste from gedit in a terminal:
- set your desktop to "focus follow mouse"
- select text in your editor
- move the mouse to the terminal
- click middle mouse button
- move the mouse back to the editor
etc...
More cumbersome but reliable.

Final note: since you are on ubuntu, you may want to change the  
terminal from the default X-term to gnome-terminal. You have to edit  
the file .vim/ftplugin/r.vim. There is a line commented with the gnome- 
terminal command instead of xterm. Uncomment this one and comment the  
xterm one.

JiHO
---
http://jo.irisson.free.fr/
#
As pointed by JiHO the biggest disadvantage of using the plugin is that
R is running through a pipe and consequently it is less interactive.
Just a note: there is no need of <Esc> before <F9>. Almost all key
bindings work in insert, normal and visual modes.

The last version of the plugin allows the user to set the terminal
emulator in the vimrc and now all key bindings are customizable. The
details are in the plugin's documentation.

Please write, to me if you find bugs in the plugin.

Jakson
JiHO wrote:
#
On 2009-May-23 , at 20:16 , Jakson Alves de Aquino wrote:

            
Well, without switching to the non-insert mode, I find that pressing  
F9 prints the commands in the file instead of executing them. Maybe  
that's specific to Cream.

JiHO
---
http://jo.irisson.free.fr/
#
Thank you much for the help, I will work on this over the weekend.  Is there
a way in Windows to connect R and Cream?
Jakson Alves de Aquino wrote:

  
    
#
JiHO wrote:
I installed and tested cream here, and <F9> in insert mode works for me,
but in few minutes I've found other problems. The customization of key
bindings in .vimrc is ignored by cream and omni completion doesn't work
correctly: cream inserts a spurious '.x:call Cream <- redo("i")' in
addition to the correct completion. It seems that cream is unable to
work properly in expert mode. Instead of using cream in expert mode it
might be easier to use gvim. Alternatively, if you prefer to use cream,
it might be easier to copy and paste commands in a regular R session
running directly in a terminal emulator because you will benefit from
R's built-in tab-completion.