Short-cut from one line to another when I edit the script
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello, I have a big script for creating many different kind of plots. Every time I print one specific kind and I choose this by setting some parameters and using a big if statement. It looks something like this.
plot_1 = 1;
plot_2 = 0;
plot_3 =0;
if plot_1
...
elseif plot_2
...
elseif plot_3
...
end
Since this script is some thousands lines, when I want to adjust one specific type of plot (say plot_15) I either have to do a search to find plot_15 or go and find it manually in the if statement, which is a bit time-consuming given the size of the script. Let me also mention that the "search" method is not that efficient either, because I sometimes use the variables plot_1 etc more than twice (in contrast to what is shown above). So even the search will not help me go to the desired line directly.
I was wondering if there is way to connect two specific lines of matlab code with a short-cut (or anything else) which I can click on and go from one to the other. I would like to have something like this:
plot_1 = 1; [short-cut or whatever that I click on and it sends me to the line of "if plot_1"]
plot_2 = 0; [short-cut or whatever that I click on and it sends me to the line of "elseif plot_2"]
plot_3 =0; [short-cut or whatever that I click on and it sends me to the line of "elseif plot_3"]
if plot_1
...
elseif plot_2
...
elseif plot_3
...
end
Let me clarify that what I am asking is something that will help me navigate better my code when I edit it -I am not asking for a go to command to be executed when the script is executed.
Thank you in advance
5 Kommentare
Walter Roberson
am 7 Mär. 2020
Bearbeitet: Walter Roberson
am 7 Mär. 2020
I just had a thought: if you grab the File Exchange contribution that saves and restores bookmarks, it would likely be possible to have it parse your .m file to find lines that you put special comments on, and add bookmarks at each of them.
However, this will not help you with hyperlinking; the old-style editor has no hyperlink operation.
If you were using Live Script then it would be possible to add markup that is hyperlink that triggers a matlab: operation to open the file to a specific line (that you could have manipulated automatically by some code that parsed the file and calculated the line numbers). See https://www.mathworks.com/matlabcentral/answers/452214-how-do-i-create-a-hyperlink-within-a-live-script-that-opens-a-simulink-model except that you would not be using open_system; see https://www.mathworks.com/matlabcentral/answers/476297-how-to-open-m-fiile-in-editor-and-move-to-specific-line-number#answer_387742
Antworten (1)
darova
am 7 Mär. 2020
There is "bookmark". Move to desired line, press Ctrl+F2 (bookmark is set)
Press F2 to move bookmark
Can you show your script? Maybe you need to use functions and script
3 Kommentare
Siehe auch
Kategorien
Mehr zu Environment and Settings finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!