A vim plugin that emulates all of the powerful IDE features of MATLAB in vim so you don't need to run the full GUI. git clone https://mcol.xyz/code/vimlab Log | Files | Refs | README | LICENSE

      1 # vimlab
2
3 This is a collection of code sourced from a few places, modified, expanded and put in one place for my own use.
4
5 It is my attempt at making vim and matlab work together as painlessly as possible. Some things are still a work in progress.
6
7 ## Features
8
9 * [Fabrice Guy's](https://www.vim.org/scripts/script.php?script_id=2407) syntax highlighting, matchit pairing of for/end, if/end etc, and indentation rules.
10 * Hitting enter in vim on a word to open it in the variable editor or in vim, if it is a variable or m file.
11 * Matlab's own keybindings for running code lines, sections, selection, script etc, using [tide](https://github.com/mcolligan/tide.git)
12 * Debugging keybindings, including setting and clearing markers and navigating the function stack
13 * Automatic session saving like in matlab
14 * Automatic/on demand code checking and error highlighting with [Thomas Ibbotson's mlint.vim](https://www.vim.org/scripts/script.php?script_id=2378)
15 * A shell script to find .m files in specified local directories and add them to the list of functions for syntax highlighting
16
17 ## Usage
18
19 ### vim
20
21 Most of the cool stuff requires vim be run in server mode. To run a vim server that can use all the functions here, including automatic session restoration, open it with:
22
23     vim --servername vimlab
24
25
26 ### Session restoration
27
28 To enable session saving and restoration, add this to your .vimrc:
29
30     let g:vimlab_session = "~/.cache/vim/sessions/matlab-session.vim"
31
32 changing the path to where you keep vim sessions, and open vim with:
33
34     vim --servername vimlab -S $HOME/.cache/vim/sessions/matlab-session.vim 35 36 You can change the default binding to save and exit (which is XA in normal mode): 37 38 nnoremap XA <Plug>VimlabEndSession 39 40 41 ### Opening variables, functions or scripts from vim* 42 43 Hitting enter when the cursor is on a word will either: 44 1. open it in the variable editor if it is a variable, or 45 2. open it in the vim server if it is a script or function and on matlabs path. 46 47 This requires the included op.m function be on matlab's path. 48 49 The default bindings are <CR> to open the word in the vim server and <Leader><CR> to open it in a new window, if the word points to an .m file. The vim server name and terminal can be changed from the default "vimlab" and urxvtc with: 50 51 let g:vimlab_server = "vimserver" 52 let G:vimlab_terminal = "xterm" 53 54 55 ### Debugging* 56 57 | Key | Function | 58 |----------------|-------------------------------| 59 | \a | **a**dd a debug marker at the current line (this saves the buffer) | 60 | \r | **r**emove the marker at the current line | 61 | \t | **t**oggle the marker at the current line | 62 | \s or F10 | **s**tep to the next line in debug mode | 63 | \c or F5 | **c**ontinue running the code | 64 | \e | toggle stopping to debug at **e**rrors | 65 | \x | e**x**it debug mode | 66 | \f | **f**lush all markers | 67 | \ds | list the debug **s**tack | 68 | \du | go **u**p the stack | 69 | \dd | go **d**own the stack | 70 71 These keybindings assume the leader key is the default backslash. 72 73 74 ### Code checking 75 76 This plugin contains Thomas Ibbotson's [mlint.vim](https://www.vim.org/scripts/script.php?script_id=2378). If mlint isn't on your system's \$PATH, you can set the path by putting this in your .vimrc:
77
78     let g:mlint_path_to_mlint = "\$HOME/applications/MATLAB/R2018b/bin/glnxa64/mlint"
79
80 This will automatically run mlint when the cursor is idle, but this can be disabled by setting this variable to anything:
81
82     let g:mlint_hover = 1
83
84 Auto linting can be toggled with the ToggleLine command, which is bound by default to <leader><br>
85
86 | Key | Function |
87 |------|---------|
88 | \ll | run mlint manually |
89 | \| | toggle automatic mlint aucommands |
90 | \lm | see the message from the current line |
91 | \lo | view an outline of all messages |
94
95
96 ### Auto close of for, if, switch statements
97
98 For, if, and switch statements will automatically get an end placed below them on the next empty line.
99 So if there is a code block on the next line, the statement will surround it. To disable this altogether, set the variable *g:vimlab_no_autoend*
100
101
102 ### Misc
103
104 For matchit word pairing of things such as if/end, allowing the use of % to navigate these pairs, add the following to your .vimrc:
105