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
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.
In Matlab editor I don't know about vim-like mode.
But you can use Vim to edit files and highlight syntax:
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
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.
-
I'm looking for vim-like bindings on the matlab command-line. For editing files, I'd just use
vim
.– user67194Jul 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
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.
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.
Install the Anaconda python distribution
Install the Matlab Engine API for Python
Install IMatlab itself (installation instructions at link)
Generate a custom config file
jupyter console --generate-config
, which will generate the filejupyter_console_config
, likely in~/.jupyter
(Linux/Mac) or%PROGRAMDATA%\jupyter
In the config file, uncomment/edit the line
c.ZMQTerminalInteractiveShell.editing_mode = 'vi'
Matlab is then run by calling the command
jupyter console --kernel imatlab