Multi-cursor Editing possibility in MATLAB Editor? - matlab

Is there a way to multiline edit code in matlab, Instead of copy-paste a single line repeatedly, or copy paste from matlab to visual studio editor to take advantage of the visual studio's alt + cursor select?

Just a quick mention that MATLAB officially support multi-line cursor since R2018a, just hold Alt and hold left mouse button (also Alt+Shift in linux) to draw a column selection across multiple lines.

Related

How to walk in vim without expanding the code that I collapsed?

I am using zc to collapse and zo to expand the code in vim.
My problem is that when I walk through the code using j and k. code that is collapsed is got expand. I want to walk through collapsed code. what can I do?
I am using vim in VScode. But the same is true if I use vim in the terminal.

How to auto-indent/-format matrices in Matlab? [duplicate]

How can I reformat code in MATLAB editor?
Other IDEs usually have reformat or format option that arrange position of written codes.
Does editor of MATLAB have it?
I use MATLAB R2013a
I have created a minimalist, configurable MATLAB source code formatter, which can be used directly in the MATLABEditor.
You can find it on GitHub: MBeautifier on GitHub
Main features:
Padding operators and keywords with white spaces
Configurable indentation character and level. Indentation using the Smart Indent functionality of the MATLAB Editor
Removal/addition of continuous empty lines
Inserting missing element separators (commas) in matrix and cell array initializations
Insert missing continuous symbol line in matrix and cell array initializations
In-lining continuous lines
Formats the current page of the MATLAB Editor or only a selection in the MATLAB Editor or file(s)
While everything above is configurable in a single XML file
It can be used in Matlab versions starting from R2013b.
Deployment and configuration are described on GitHub (link above).
A few default formatting shortcuts for the Matlab editor - assuming windows
ctrl+A - Select all
ctrl+I - Smart Indend
ctrl+= - Collapse All (loop control statements)
ctrl+shift+= Expand All (loop control statements)
ctrl+] - Increase indent
ctrl+[ - Decrease indent
ctrl+J - Wrap comments
Other useful keyboard shortcuts for Matlab editor
ctrl+R - Comment out selection (adds leading % to all selected lines)
ctrl+T - Uncomment selection (removes leading % from selected lines)
ctrl+K - Kill line (deletes from caret to end of line, if line is empty deletes newline)
ctrl+M - View or expand current message
ctrl+F1 - Display function hints
Additional shortcuts can be found or defined in Prefrences>Keyboard>Shortcuts
Finally a special mention to ... for line continuation...
example:
[output1,output2,output3]=calltoafunctionwithlotsofinputs(...
intput1, input2, input3, input4, input5, ...
'property1', propertyvalue1, ...
'property2', propertyvalue2)
While not fulfilling the "in the editor" part of your question, there is another MATLAB style checker / code formatter: https://github.com/florianschanda/miss_hit

How to copy (to clipboard) only significant part of a plot in Matlab?

How to copy (to clipboard) only significant part of a plot in Matlab? Without that large gray margins Matlab loves so much?
Is it possible to populate clipboard from Matlab command line?
As far as programmatically populating the system clipboard with image data captured from a Matlab figure goes, you might try Yair Altman's, ScreenCatpture utility on the Matlab File Exchange:
screencapture('handle',gca,'target','clipboard');
It has a lot of options and will allow you to specify a region or an entire figure. It does require Java, i.e., it won't run in '-nojvm' mode. You can read more about it at Yair's Undocumented Matlab site.
Also, you can change the current figure's background color to white before copying it via:
set(gcf,'Color','w');
In the figure window, choose "edit" -> "Copy Figure".
It's equal to Ctrl+C on text, etc., but takes only the main part of the figure. So if you go to word, say, and press Ctrl+V, or RIght Click -> Paste, you will get only the main part of figure, without the gray margins you hate so much...

Basic Cursor Movement Between Paragraphs in Matlab Editor

Is there a way to move between paragraphs in the Matlab Editor as is a common feature in any other general text editor out there. ie.
Ctrl+Up and Ctrl+Down to Move cursor between paragraphs as in Winedt.
I don't think there is such a shortcut. I must admit I have never missed it myself - what would a "paragraph" in your code be defined as?
BTW, are you aware that Ctrl+Down is used to go from one Cell to the next in MATLAB's cell mode? Cells could be considered logical "paragraphs" of your code, and you set their limits themselves (with comment lines starting with a double %%).

How do I rearrange a split pane in Emacs?

In Vim I can move a split around. For example, if my window was split in two horizontally, with the topmost split split vertically (3 splits in total) I could move the top-right split to the right to become a vertical split taking up the entire vertical space.
Is this kind of rearrangement possible?
Update: I know resizing is possible, I'm looking to move though. I get the feeling this is not supported by Emacs.
You may be interested by C-x + when you have more than 2 windows. It rearranges equally the windows on the frame. It's convenient for example when you do two C-x 2 in a row and want to have the windows to occupy the same space on the frame.
No, not by default. What you have to play with is basically C-x 0, C-x 1, etc. Look in the Emacs Wiki for extensions that may or may not do what you're looking for.
FWIW, if you are running within a GUI, then you can precisely re-arrange window sizes quickly and easily with the mouse. This isn't quite the same thing as you're asking for, but may be a handy alternative in some cases.
You can click on any non-'active' area of the mode line (such as the buffer name) and then drag it up or down.
Dragging side to side is more fiddly. You must click on the exact border between the two mode lines, and then you can drag left/right.
For your specific example, I don't believe that is supported. AFAIK you can only reorganise the window splits within their existing 'parent' window (the upper split in this example). To make the upper-right window fill the vertical space you would either remove the bottom window with C-x 0, or use C-x 1 to remove all other windows, and then re-split them in the desired manner.
(Tangentially, I've often thought a custom library to 'rotate' the window splits would be a nice thing to have.)
I believe that the window resize commands are built in to window.el, from emacswiki the functions you want documented are:
shrink-window-horizontally ; C-x {
enlarge-window-horizontally ; C-x }
enlarge-window ; C-x ^
shrink-window ; not bound on my system
The comments are what they are bound to on my system, but I don't know if I did that myself.
All of them take a prefix argument, the number of lines to enlarge/shrink. The last two default to vertical.
As far as I know you cannot create a new window that runs the length or width of the screenfrom a window already split in that direction. Buffers remain open if you close the windows though so you can remove windows and then split them in the configuration you want. Then change which buffer is displayed in the window you are standing in by pressing C-x left arrow or right arrow.
I should add that this answer is regarding "vanilla" emacs, there is probably a way of doing what the OP asks if you really want to. It's emacs after all.