You are not logged in.
Hey AUR Forum im back again
I wanted to heir if some of you have a suggestion.
I wanna know is there a way or allready made a way to add a template folder for Vim.
Say something like this:
/home/user/path/to/some/folder/contaning/Templates/PythonThreading
and then to use a command something like this when creating a new file:
vim SomeName.py --Temp-PythonThreading
Then the file being open is the new file "SomeName.py" but it now contains what ever the template contains.
Say something like
#!/usr/bin/env python3
#Imports
Something
#Main loop for starting threads.
While true
The point is that you can all any kind of templates and you dont have to do the standard start op setting up with different kind of stuff, i mainly want this because constently adding, lirbarys when coding for an ESP32 as an example.
it gets boring after a while and waste quit a bit of time.
Last edited by ELODollZ (2024-04-19 10:18:44)
Offline
This appears to be an xy-problem.
If you write the same boilerplate code over and over again, you should consider using a more appropriate design pattern or use appropriate libraries to spawn concurrent tasks.
Inofficial first vice president of the Rust Evangelism Strike Force
Offline
it's not so much as a lirbary im searching, im more searching for where i can add templates, for different languages, so that i don't have to recreate basic formatting all over when starting new projects, and the main reason is to get a call able template for LaTeX which i use for my reports for my school, but having to set up the headers and all that over and over, even if i just copy past it in, it would be nice to just be able to just create it from a template.
To save more time.
I havn't been able to find anything, so i was thinking just making some sort of scuffed function that takes a "Vim SomeName.Tex --temp-StandardReport.tex" and then does all the steps that i normally take, to get a project started.
But i wanted to know if there was allready a program of some sort that allready does this. Was thinking to make it difference between different Editors to make it use "Vim" or "Nano" and then match my spelling and not casing since vim and nano don't get called if they are capitalized letters in them, but this again is really a scuffed way of doing it, and not very edit/upgradeable friendly
Offline
#!/usr/sbin/env /usr/sbin/bash
vim.template ()
{
local help='[source file name] [template file name without py suffix]';
local python_template_dir=/usr/local/lib/python/template;
local source=${1:?$help};
local template=${2:?$help};
if [[ -a $source ]]; then
echo "File $source already exists.";
return;
fi;
if [[ ! -a "$template".py ]]; then
if [[ ! -a "$python_template_dir/$template".py ]]; then
echo "Invalid $template";
return;
fi;
template="$python_template_dir/$template".py;
fi;
/usr/sbin/cp $template $source;
\builtin exec /usr/sbin/vim $source
}
vim.template $@
Last edited by solskog (2024-04-19 13:46:30)
Offline