VimLab replicates MATLAB's support for code sections in Vim. It uses tmux to maintain a MATLAB session from within vim.
VimLab relies on tmux and screen.vim which are used to set up and communicate
with a MATLAB session. It expects the matlab
command to be on your $PATH
.
Code analysis, similar to that offered by MATLAB's editor, is provided by the
excellent Syntastic plugin. If mlint
is on your path as well, Syntastic will
automatically analyze your MATLAB code when it's saved.
VimLab requires vim to run inside a tmux session. Linux users may find a tmux package is provided by their favorite distribution. For OS X users, I recommend installing tmux using homebrew.
For a well written introduction to tmux, please take a look at the book "tmux: Productive Mouse-Free Development" by Brian P. Hogan.
VimLab uses Screen.vim to manage a MATLAB session within tmux.
Install Syntastic if you wish to have your MATLAB code automatically analyzed when it is saved.
I recommend installing VimLab using Vundle. Add the following lines to your .vimrc file:
Bundle "ervandew/screen"
Bundle "dajero/VimLab"
"Optional, if you desire automatic code analysis
Bundle "scrooloose/syntastic"
Next, either quit and relaunch vim or source .vimrc
from within your current
vim session. Finally, issue the :BundleInstall
command to vim to install
VimLab and its dependencies.
VimLab automatically creates a few key mappings when you enter a MATLAB buffer.
These mappings are prefixed by your leader, which defauls to \
. If you set
your mapleader to a different character, please mentally substitute the
backslash by the mapleader
of your choice.
\mm
starts matlab\ms
sends the current section to MATLAB\md
open the documentation for the current word\mh
show help for the current word\mv
show the variable the cursor is ongn
go to the next sectiongN
go to the previous section
VimLab also provides two commands to quickly open the documentation or help for a function:
:MATDoc my-function
opens the documentation for my-function:MATHelp my-function
shows help for my-function
By default, VimLab splits your tmux window horizontally to create a pane for
MATLAB. If instead, you prefer the panes to be arranged vertically, set the
varible g:matlab_vimlab_vertical
to 1
, e.g. add the following line to your
.vimrc
:
let g:matlab_vimlab_vertical=1