Automatically insert end for if statements and for loops

7 Ansichten (letzte 30 Tage)
Joel Hochstetter
Joel Hochstetter am 15 Mai 2019
Kommentiert: Walter Roberson am 18 Okt. 2022
Hi,
How do you get Matab to automatically insert "end" when you type "if" or "for" in a script?
  2 Kommentare
John D'Errico
John D'Errico am 15 Mai 2019
Bearbeitet: John D'Errico am 15 Mai 2019
Why is it difficult? You can't type three more characters? ... end? Life is tough. Seriously, very difficult?
When you type an if (or for) statement, immediately hit a return, then type end. Now you can insert anything you want in between. WTP?
Edit: I see that Joel no longer claims that needing to type an end is a terrible thing for humanity, and the world may come to an end due to that requirement.
Horia Ghionoiu Martínez
Horia Ghionoiu Martínez am 23 Apr. 2020
I would find it useful, as in Visual Studio you have the autofill function for frequently used statements, like the if statement -> the IDE completes for you the repetitive task of writing if(true) {...your code...}, and then you can start coding away, without needing to write the same syntax one thousand times.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

madhan ravi
madhan ravi am 15 Mai 2019
Bearbeitet: madhan ravi am 15 Mai 2019
It's possible in live editor.
  3 Kommentare
Steven Lord
Steven Lord am 18 Okt. 2022
In the Editor/Debugger Preferences click on the "Automatic Completions" entry. On that page of preferences, check if "Control flow statements (if, for, etc.)" is checked. If it is not, check it.
Walter Roberson
Walter Roberson am 18 Okt. 2022
https://www.mathworks.com/help/matlab/matlab_env/about-editor-debugger-preferences.html#mw_32cf4c57-16be-42f8-96d3-a6710176971c automatic completion of block ending

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by