ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Auto​Matlab

by asparc ST3 Win

Sublime Text plugin with autocompletion, documentation generation and a command panel for Matlab.

Details

Installs

  • Total 88
  • Win 88
  • Mac 0
  • Linux 0
Mar 9 Mar 8 Mar 7 Mar 6 Mar 5 Mar 4 Mar 3 Mar 2 Mar 1 Feb 28 Feb 27 Feb 26 Feb 25 Feb 24 Feb 23 Feb 22 Feb 21 Feb 20 Feb 19 Feb 18 Feb 17 Feb 16 Feb 15 Feb 14 Feb 13 Feb 12 Feb 11 Feb 10 Feb 9 Feb 8 Feb 7 Feb 6 Feb 5 Feb 4 Feb 3 Feb 2 Feb 1 Jan 31 Jan 30 Jan 29 Jan 28 Jan 27 Jan 26 Jan 25 Jan 24 Jan 23
Windows 1 1 2 0 3 2 4 0 2 3 0 2 3 3 0 3 0 0 3 1 1 0 0 0 0 1 4 1 3 0 2 1 1 2 1 2 1 0 3 1 3 2 5 3 1 1
Mac 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Linux 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Readme

Source
raw.​githubusercontent.​com

AutoMatlab

AutoMatlab makes writing Matlab code fun again by combining the strengths of Sublime Text with the strengths of Matlab.

Features:

  • Autocomplete any Matlab function!
  • Run Matlab commands from within Sublime Text!
  • Generate context-aware Matlab function documentation!

Table of Contents:

Getting started

  • Autocompletion Works out of the box! Start typing or try pressing Ctrl + Space to see what it does. If you are interested in more tailored functionality, have a look here.
  • Matlab commands Depends on AutoHotkey. If AutoHotkey is installed and auto_hotkey_path correctly specified in the AutoMatlab settings, try pressing Ctrl + b to run the current file in Matlab or Alt + m to open the AutoMatlab Command Panel. If you are interested in more tailored functionality, have a look here.
  • Function documentation generation Works out of the box! Try pressing Ctrl + Alt + m in a Matlab function file to see what it does. If you are interested in more tailored functionality, have a look here.

Note: AutoMatlab currently only supports Matlab installations on Windows.

Autocompletion

AutoMatlab offers extensive autocompletion functionalities, which are a substantial improvement over the very limited built-in autocompletion functionalities of the Matlab Editor.

Features:

  • Autocompletion on multiple levels: Matlab-wide, project-wide, folder-wide, file-wide.
  • Customizable autocompletion sources.
  • Documentation pop-up similar to Matlab's help.
  • Responsive See also hyperlinks.

Autocompletion suggestions will be automatically shown while typing, but can also be queried via the default keyboard shortcut Ctrl + Space.

Command panel

When the typed text exactly matches a function name, querying the autocompletion with Ctrl + Space yields a list of suggested function signature snippets, as well a pop-up with the function documentation.

Command panel

Matlab autocompletion

AutoMatlab comes by default with autocompletion information for about 3000 built-in Matlab functions. As Matlab installations and user preferences differ, this information can be adjusted to a specific Matlab installation via the below steps:

  1. Open the AutoMatlab settings:
    • Specify the Matlab installation path via matlabroot.
    • (Optional) Specify the pathdef.m path via matlab_pathdef_path.
    • (Optional) Fine-tune the sources for the autocompletion information in the section Matlab autocompletion sources. All fine-tuning options are documented in the default AutoMatlab settings file.
  2. Open the Sublime Command Palette:
    • Run AutoMatlab: Generate Matlab autocompletion information. AutoMatlab will parse the specified directories, searching for Matlab functions that adhere to the documentation format used by The MathWorks.
    • Wait for the process to finish (see status bar). This can take several minutes, depending on the Matlab installation.
  3. Done! The newly generated autocompletion information is stored in Packages\AutoMatlab\data\matlab_completions.

Project autocompletion

AutoMatlab provides autocompletion information for Matlab functions in the currently active Sublime project. AutoMatlab updates this information each time files within the project are saved.

The following settings can be added to the .sublime-project file to adapt the autocompletion sources on a per-project basis. These options work identically to the corresponding options in the default AutoMatlab settings file, where they are documented.

{
    "auto_matlab":
    {
        "include_dirs": [],
        "exclude_dirs": [],
        "exclude_patterns": [],
        "free_documentation_format": true
    }
}

Current folder autocompletion

AutoMatlab provides autocompletion information for Matlab functions in the currently opened folder(s). AutoMatlab updates this information each time files inside the folder(s) are saved.

Current file autocompletion

AutoMatlab provides autocompletion information for local Matlab functions inside the currently opened file. AutoMatlab updates this information each time the file is saved or activated.

Matlab commands

If AutoHotkey is installed, AutoMatlab can send commands to Matlab, to be run in Matlab's Command Window.

AutoMatlab Command Panel

Command panel

The AutoMatlab Command Panel can be accessed through the Sublime Command Palette or via Alt + m. It shows command suggestions from the recent Matlab history. If no history is shown, make sure matlab_history_path is correctly set in the AutoMatlab settings.

Through the AutoMatlab Command Panel, commands can be transferred to Matlab:

  • Enter Run the selected history entry in Matlab.
  • Insert the selected history entry into the AutoMatlab Command Panel.
  • Tab Run the input from the AutoMatlab Command Panel in Matlab.

Predefined commands

A number of useful Matlab commands have been predefined. They can be run through the Sublime Command Palette or via keyboard shortcuts. Some examples:

  • Ctrl + b Run the current file in Matlab.
  • Ctrl + Shift + b Change the current folder and run the current file in Matlab.
  • Alt + . Set a Matlab breakpoint at the current line.
  • Alt + , Clear the Matlab breakpoint from the current line.

Custom commands

It is possible to define custom Matlab commands, which can be assigned to keyboard shortcuts or added to the Sublime Command Palette. For custom Matlab commands, use the AutoMatlab command run_matlab_command as follows:

{
    "caption": "AutoMatlab: Print status",
    "command": "run_matlab_command",
    "args": {"command": "disp('I am editing file $file_name at line $line.')"}
}

The AutoMatlab command run_matlab_command will expand the default Sublime Text variables, such as $file, $file_name, $file_base_name, $folder, and $project_name. Additionally, AutoMatlab defines the following variables:

  • $line: The currently active line.
  • $column: The currently active column.
  • $package_member: The name of the currently opened Matlab file, including the package namespace. Example: C:\Users\Foo\myproject\+mypack\myfun.mmypack.myfun.
  • $package_parent: The path of the parent directory for the currently opened Matlab package. Example: C:\Users\Foo\myproject\+mypack\myfun.mC:\Users\Foo\myproject.

Function documentation generation

AutoMatlab provides flexible and context-aware function documentation generation, based on a customizable template snippet. Function documentation can be generated through the Sublime Command Palette or via the keyboard shortcut Ctrl + Alt + m.

Predefined documentation template snippets

AutoMatlab provides a number of predefined documentation template snippets. These template snippets follow the function documentation format that is employed by The MathWorks: they comprise a one-line function description and at least one function signature. Furthermore, they are adaptive, in the sense that they substitute elements from the function definition into the snippet.

In the AutoMatlab settings, a predefined documentation template snippet can be selected by setting documentation_snippet to one of the following values:

  • matlab_documentation.sublime-snippet (default)

Template snippet default

  • matlab_documentation_args.sublime-snippet

Template snippet args

  • matlab_documentation_args_in_out.sublime-snippet

Template snippet args in out

Custom documentation template snippets

AutoMatlab also supports custom documentation template snippets. To create those, start from the below example, add/remove/adapt as desired, and save the result as a .sublime-snippet file. Finally, set the documentation_snippet in the AutoMatlab settings to the name or path of the created template snippet.

<snippet>
<description>Matlab documentation</description>
<content><![CDATA[ 
%${MDOC_NAME} ${1:<one line description>}${MDOC_NAME_MARKER}
%
% ${MDOC_SIGNATURE} ${2:<explain usage>}${MDOC_SIGNATURE_MARKER}
% 
% Input:${MDOC_INARG_BLOCK_MARKER}
%   - ${MDOC_INARG}: ${3:<description>}${MDOC_INARG_MARKER}
%
% Output:${MDOC_OUTARG_BLOCK_MARKER}
%   - ${MDOC_OUTARG}: ${4:<description>}${MDOC_OUTARG_MARKER}
% 
% ${MDOC_ARG_BLOCK_MARKER}
% ${MDOC_ARG}: ${5:<description>}${MDOC_ARG_MARKER}
%
% See also ${6:<list related>}${MDOC_SEE_ALSO_MARKER}

% Author(s): ${7:<authors>}${MDOC_AUTHOR_MARKER}
% Copyright ${8:<year>} ${9:<owner>}${MDOC_COPYRIGHT_MARKER}
]]></content>
<scope>source.matlab</scope>
</snippet>

Project-specific documentation format

The following settings can be added to the .sublime-project file to adapt the generated function documentation on a per-project basis.

{
    "auto_matlab":
    {
        "documentation_upper_case_signature": true,
        "documentation_snippet": "mysnippet.sublime-snippet"
    }
}

Roadmap

  • [ ] Support for Matlab classes
    • [ ] Class autocompletion
    • [ ] Class documentation generation
  • [ ] Support for other OS's
    • [ ] Mac
    • [ ] Linux