Is there a way to modify default function template

10 visualizaciones (últimos 30 días)
lewww
lewww el 31 de Mayo de 2021
Comentada: lewww el 1 de Jun. de 2021
When I use the New > Function button and name the created file it generates a default function code with the appropriate name. The generated function has 2 default input variables and output variables and some useless code copying the inputs to the output. Whenever I create a function like this I have two options
  1. Remove/rename the relevant sections of the function (input, output, code inside)
  2. Delete the entire function and type it out from scratch
Both options are annoying, especially doing it every time in a larger project. Is there a way to modify this default function creation. I would like to keep the matching names but rather have something like this
function [] = AssignedName()
end
  5 comentarios
John D'Errico
John D'Errico el 31 de Mayo de 2021
Editada: John D'Errico el 31 de Mayo de 2021
Apparently, the idea is not one that has been deemed important enough to do something about. You can always submit an enhancement request. Surely, it does not take that much effort to select a block of text, and click on the delete key. Are you creating that many thousands of new files, that this is a serious problem? Personally, having written many thousands of m-files over the years, one would think it would drive me crazy, IF it was really an issue. Not so.
And really, the link that Geoff shows does provide a simple way to populate a new file as you like it. What about that is inadequate?
lewww
lewww el 1 de Jun. de 2021
"Apparently, the idea is not one that has been deemed important enough to do something about."
Here are a few file exchange entries addressing exactly this:
I will definitely make a request. I suspect there are many others having this issue but they do nothing and live with this inadequate software. The problem is that if I want to call functions from the command line I have to create function files. This forces me that for every little script I create and test I need to create new functions. The functions come with this stupid template having unnecessary input, output variables and code inside. What is their purpose? To showcase absolute beginners how to have input and output variables? How to assign the input to the output? How to write documentation?
Let's contrast it with say Visual Studio. On creating a new class for example, we get the bare minimum. But even if someone wants a something extra there are templates.

Iniciar sesión para comentar.

Respuestas (1)

Jan
Jan el 31 de Mayo de 2021
  1 comentario
lewww
lewww el 31 de Mayo de 2021
Thank you for the reference. But this is not what I'm looking for. I would like to change the built in ".template" files for new functions.

Iniciar sesión para comentar.

Categorías

Más información sobre Startup and Shutdown en Help Center y File Exchange.

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by