Vim-like input for Matlab

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?


Solution 1:

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.

Solution 2:

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.

Solution 3:

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.