MATLAB Snippets App adds code snippets to the Matlab editor. Snippets definition uses syntax compatible with the Visual Studio Code and with the Textmate 1.x. The integration to the Matlab editor is loose, the snippets are inserted by a keyboard shortcut (usually <ALT+1>).
See the Github project page for the animated App use examples:
https://github.com/trnkap/matlab-snippets
Features:
* snippets can contain tabstops with default values (placeholders)
* any tabstop value can be mirrored on multiple locations in the snippet
* variables containing currently selected text, currently edited filename, etc. can be used
* tabstop mirroring and variables can be altered by regular expressions
Pavel Trnka (2021). MATLAB Snippets (https://github.com/trnkap/matlab-snippets), GitHub. Retrieved .
Inspired by: Insert a piece of code (a snippet) in the Matlab editor, JSONLab (Development Branch), findjobj - find java handles of Matlab graphic objects
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Create scripts with code, output, and formatted text in a single executable document.
R2018b, Win10 "Swedish". The choices by up/down arrows in matlab-examples.json / example06 just didn't work. It turned out that adding Swedish keywords to insertSnippet() line 635-640
switch char(keyData.getKeyText(keyData.getKeyCode))
case {'Up','Upp'} % 2020-09-22, poi: Added 'Upp', Swedish for 'Up'
choice = current.tabstopObject.getPreviousChoice();
case {'Down','Nedpil'} % Added 'Nedpil', Swedish for 'DownArrow'
choice = current.tabstopObject.getNextChoice();
end
made the feature work as advertised. Is translating keywords some kind of practical joke by Ms?
Now I added my own json-file.
I assume it's possible to add a user defined json-file with snippets definitions. However, so far I failed to add my own json-file. I created the file, added it to the snippets-folder, added the name to the opt.jsonFileNames in insertSnippet/loadOptions() and the finally to insertSnippetOptions.mat. No error messages, just silence. Help!
oh my god! this is pure Gold! thank you so much!
i have always dreamt of something like this!
Thank you!
Finally a tool that helps to keep a high coding standard almost effortlessly.