7

With a .inputrc file, I can do vim-like editing in maple. Is there a way to get vim-like line input in Matlab, either for the command-line or the GUI?

4 Answers 4

4

Matlab doesn't use GNU readlines, so there's no direct way to bind vim keys to the Matlab command line through your ~/.inputrc. You'd have to create a wrapper that captures your vim code on a line-by-line basis. This SO link should get you started.

1

In Matlab editor I don't know about vim-like mode.

But you can use Vim to edit files and highlight syntax:

  1. you can use Vim in Windows downloading it from http://www.vim.org/download.php or using Cygwin and installing the right package. Then, to use Matlab syntax highlight, download it from http://www.mathworks.com/matlabcentral/fileexchange/21798-editing-matlab-files-in-vim

  2. you can use Emacs instead: http://blogs.mathworks.com/desktop/2009/09/14/matlab-emacs-integration-is-back/ . There, they say that you can use Vim only changing some parameters in their solution.

2
  • I'm looking for vim-like bindings on the matlab command-line. For editing files, I'd just use vim.
    – user67194
    Jul 7, 2011 at 22:13
  • Ya exactly... that's probably the best you will get because Matlab is not the most open program. I'm not even sure if you can write your own plugins for Matlab IDE/GUI. Apr 13, 2012 at 19:42
1

Set your bash or zsh console to vim mode using bindkey -v. Then install the rlwrap commmand line utility. Then make a nice alias to start matlab with vim for it's command line.

alias vmatlab="rlwrap -a matlab -nodesktop -nosplash"

To start using matlab with vim at the console, in a new terminal, type vmatlab.

It basically works. I used vim at the matlab console. But one side effect is that it fubars tab-completion in matlab. There's a way around it using rlwrap filters, but I don't have enough knowledge about them to write one.

0

A summary from the Brushing Up Science post for recent versions of Matlab (R2016b or later)

To get Vim bindings for Matlab at the command line, use IMatlab: a Jupyter kernel for Matlab.

  1. Install the Anaconda python distribution

  2. Install the Matlab Engine API for Python

  3. Install IMatlab itself (installation instructions at link)

  4. Generate a custom config file jupyter console --generate-config, which will generate the file jupyter_console_config, likely in ~/.jupyter (Linux/Mac) or %PROGRAMDATA%\jupyter

  5. In the config file, uncomment/edit the line c.ZMQTerminalInteractiveShell.editing_mode = 'vi'

  6. Matlab is then run by calling the command jupyter console --kernel imatlab

You must log in to answer this question.