You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
hello hello! Thank you for creating babi as well as for all of your other educational material! I've been using babi and was wondering about a possible new feature which would (optionally) populate the editor with template text when creating a new file. After looking through the source code, here is one idea I've come up with for how this might be implemented.
Add an optional command line argument indicating whether to use a template (and if so which. only applicable if no filename is given or if the given filename doesn't exist)
In the case where the passed filename does not exist or filename is None, instead of passing the empty string to get_lines, call a function which returns a string to pass in based on that command line argument (and perhaps other info).
Create babi/resources/templates.py which will:
a. Store various text templates
b. Contain the function referenced in 3.
If we think there would reasonably be only one template per file extension, then I'd lean toward making the command line argument a flag and then parse the filename to determine which flag to use. Then we could have something like babi t.py --template yielding
If not, then I think the command line argument would need to indicate which template to use.
I'd be very interested in hearing your thoughts. Thanks for your time and consideration!
The text was updated successfully, but these errors were encountered:
I don't think a command line argument is a good idea as it's really only usable outside the editor (and only on empty files). I was thinking more of a <esc> command like :m macroname and a way for the user to have snippets in ~/.config/babi/snippets/... or something
hello hello! Thank you for creating babi as well as for all of your other educational material! I've been using babi and was wondering about a possible new feature which would (optionally) populate the editor with template text when creating a new file. After looking through the source code, here is one idea I've come up with for how this might be implemented.
babi/resources/templates.py
which will:a. Store various text templates
b. Contain the function referenced in 3.
If we think there would reasonably be only one template per file extension, then I'd lean toward making the command line argument a flag and then parse the filename to determine which flag to use. Then we could have something like
babi t.py --template
yieldingIf not, then I think the command line argument would need to indicate which template to use.
I'd be very interested in hearing your thoughts. Thanks for your time and consideration!
The text was updated successfully, but these errors were encountered: