Vim Tips Wiki

Run matlab script

Revision as of 14:03, February 12, 2014 by Memming (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
1,619pages on
this wiki

Proposed tip Please edit this page to improve it, or add your comments below (do not use the discussion page).

Please use new tips to discuss whether this page should be a permanent tip, or whether it should be merged to an existing tip.
created July 30, 2012 · complexity basic · version 7.0

I added the following to my vimrc to be able to run a Matlab script by pressing F5 (with Shift-F6 you run Matlab in a terminal):

" The matlab Connection
nnoremap <F5> :call MatlabRun()<CR><CR>
nnoremap <S-F6> :call RunMatlab()<CR><CR>

function! MatlabRun()
  execute "w"
  execute "! \"". expand("%:r") . "\""

function! RunMatlab()
  execute "w"
  call system(" \"" . expand("%:r") . "\"")

I have the following scripts in my $PATH:


from subprocess import call
from subprocess import check_output
import sys

wcmd = ["xdotool","search","--name","MatlabT"]
w = check_output(wcmd)
w = w.replace('\n','')

if len(sys.argv) > 1:
  s = sys.argv[1]

cmd = ["xdotool","key","--window",w]

for i in range(len(s)):



terminal -e "/opt/MATLAB/R2011a/bin/matlab -r clc -nosplash -nodesktop" -T MatlabT --hide-menubar &> /dev/null &
# try to return focus to GVIM
xdotool search --class --name "${texfile}.*GVIM" windowactivate &>/dev/null
exit 0


- tmux + Slimux is an alternative --Memming (talk) 14:03, February 12, 2014 (UTC)

Around Wikia's network

Random Wiki