[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What editor to use in combination with octave?

From: Marius Roets
Subject: Re: What editor to use in combination with octave?
Date: Mon, 30 Aug 2010 19:37:10 +0200

> > It should be easy to integrate any text editor that supports macros, on
> Linux using the screen application. If anybody is interested, and can show
> how I did this for Vim (my editor of choice). I have integrated it in such a
> way that I can run portions of code, or the whole file. I use KDE, but none
> of the ideas is KDE specific.
> Marius

I am also a vim user and would very much like to hear about the way you
integrated it.
Thanks, Avraham
Please avoid sending Excel or Powerpoint attachments to this address.

I have created a vim script called screen-send.vim with the following content :
let s:cmd = "!screen -x ".b:screen_send_screen_name." -X stuff"

function! SendFile()
   let dir = getcwd()
   let l = "cd ".dir
   call SendLine(l)
   call SendLine(b:screen_execute_cmd)

function! SendCurrentLine()
   call SendLine(getline("."))

function! SendLine(l)
   let cmd = s:cmd." $'".a:l."\\n'"
   execute cmd

function! SendCurrentBlock()
   let lines = getline("v", ".")
   for l in lines
      call SendLine(l)

nnoremap <F9> :w<cr>:call SendFile()<cr><cr>
nnoremap <S-F9> :call SendCurrentLine()<cr><cr>
vnoremap <S-F9> :call SendCurrentBlock()<cr><cr>

And a file called octave.vim with :
" Sending file content to screen session
let b:screen_send_screen_name = "octave"
let b:screen_execute_cmd = expand("%:t:r")
source ~/.vim/after/ftplugin/screen-send.vim

Both go in ~/.vim/after/ftplugin

Then in a terminal, I start a screen session :
> screen -s /usr/bin/octave -S octave

Back in Vim, Shift-F9 will send the current line or highlighted text (depending on normal or visual mode) to the screen session. F9 will send the entire file.
I usually have the terminal with the screen session and Vim open side by side, so that I can immediately see the effect of my code. I use the same method for Python and other interactive sessions.

I have hacked this together from examples, so for instance, I'm not sure what the significance of the "stuff" word is, but it seems to not work without it.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]