Indent a block of code

How do you indent a block of code? For example if you enclose a block of code in an if statement, and want to indent said block.

 Respuesta aceptada

Wayne King
Wayne King el 29 de Oct. de 2011

0 votos

In the MATLAB editor, you should automatically get identation of an if statement.
Other than that, highlight the text and do Text -> Small Ident, or Text -> Increase Ident

Más respuestas (2)

Image Analyst
Image Analyst el 30 de Oct. de 2011

17 votos

Highlight the lines of text. Then hit tab to indent them a level to the right, and shift-tab to outdent them a level to the left.
Rachel Allen
Rachel Allen el 8 de En. de 2021

5 votos

You can also use smart indent
select code then 'ctrl I'
or
select code -> right click -> Smart Indent

1 comentario

Image Analyst
Image Analyst el 8 de En. de 2021
I often just type control-a (to select all) and then control-i (to properly indent the entire file).

Iniciar sesión para comentar.

Categorías

Más información sobre App Building en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 29 de Oct. de 2011

Comentada:

el 8 de En. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by