Snippets for external command output?
-
- Posts: 5
- Joined: 23.05.2022 21:19
Snippets for external command output?
Hello,
It's been a pleasure to use CudaText so far. I have a question about snippets, as I couldn't find related information in the help documentation.
I have a lot of scripts and programs that output text, which I use in the text editor.
For example a program that outputs a schedule outline in Markdown, starting with the current time. Or a script that brings in text from a given external text file, in a specific format.
Typically I would type the snippet name and press (tab) in my editor to see it replaced by the command output.
Is there a way to do this in CudaText? Thank you.
It's been a pleasure to use CudaText so far. I have a question about snippets, as I couldn't find related information in the help documentation.
I have a lot of scripts and programs that output text, which I use in the text editor.
For example a program that outputs a schedule outline in Markdown, starting with the current time. Or a script that brings in text from a given external text file, in a specific format.
Typically I would type the snippet name and press (tab) in my editor to see it replaced by the command output.
Is there a way to do this in CudaText? Thank you.
-
- Posts: 2323
- Joined: 25.08.2021 18:15
I don't get the idea - e.g. you type what? and what command is executed from this snippet name? how command is defined for the snippet?
CudaText "Snippets" plugin
https://wiki.freepascal.org/CudaText_plugins#Snippets
can insert fixed text which is defined in the snippet storage (one snippet name - one fixed text, no command is used)
CudaText "Snippets" plugin
https://wiki.freepascal.org/CudaText_plugins#Snippets
can insert fixed text which is defined in the snippet storage (one snippet name - one fixed text, no command is used)
-
- Posts: 5
- Joined: 23.05.2022 21:19
Here are some examples, I have about 90 of these in the configuration.
These are placed in the snippets configuration file of my other editor.
Then if I type wk, ak, sk, or st and press the tab key, the corresponding command is executed and the output is placed at my cursor. Usually it is multiple lines of output.
It seems this may not be possible? But I'm curious if there could be any workarounds to get the same result. Thank you.
Code: Select all
wk=\n{command:cat /home/user/Dropbox/User/Writing/Current\ Writing\ Projects/Weeklies.md}\n\n
ak=\n{command:cat /home/user/Dropbox/Client\ Notes/notes/Active-Client-Projects.md}\n\n
sk=\n{command:/home/user/Dropbox/bin/schedwriter}\n\n
st={command:/home/user/Dropbox/bin/stockprices}
Then if I type wk, ak, sk, or st and press the tab key, the corresponding command is executed and the output is placed at my cursor. Usually it is multiple lines of output.
It seems this may not be possible? But I'm curious if there could be any workarounds to get the same result. Thank you.
-
- Posts: 2323
- Joined: 25.08.2021 18:15
-
- Posts: 5
- Joined: 23.05.2022 21:19
I'm glad to hear you think so. This editor is Geany.main Alexey wrote:'of my editor' - what editor do you use, Sublime? Atom?
it is interesting idea! to support {command:xxxx}. It is worth to support it. I will try that later.
The documentation is here: https://www.geany.org/manual/current/in ... e-snippetsDo you mean support it in something like Vim command mode? a command line (like some CAD Software)? or something different?
There is no command mode or command line mode, just typing in the document at your cursor. But I wouldn't be angry if those others were also supported.

-
- Posts: 2323
- Joined: 25.08.2021 18:15
I changed the Snippets plugin. please test.
"Plugins / Addon Manager / Install from git", enter URL
https://github.com/cudatext-addons/cuda_snippets
The macro ${cmd:xxxxxxxxxx} was added.
I tested it on a new snippet with such body:
You can add snippet via "Plugins / snippets / Add-edit snippets".
"Plugins / Addon Manager / Install from git", enter URL
https://github.com/cudatext-addons/cuda_snippets
The macro ${cmd:xxxxxxxxxx} was added.
I tested it on a new snippet with such body:
on Ubuntu.result: ${cmd:cat ~/paste.txt}
You can add snippet via "Plugins / snippets / Add-edit snippets".
-
- Posts: 5
- Joined: 23.05.2022 21:19
That was fast! This works well for me overall; I tested it with some of my scripts already and the results look good.main Alexey wrote:I changed the Snippets plugin. please test.
"Plugins / Addon Manager / Install from git", enter URL
https://github.com/cudatext-addons/cuda_snippets
The macro ${cmd:xxxxxxxxxx} was added.
I tested it on a new snippet with such body:
One issue comes up though, this is a Pascal program and somehow after execution the editor moves my cursor very far to the right (horizontal scrollbar becomes tiny) after execution, without adding actual spaces to the file.
Can I ask if this happens for you too? Version 1.165.0
Code: Select all
${cmd:~/Dropbox/bin/schedwriter}
-
- Posts: 2323
- Joined: 25.08.2021 18:15
-
- Posts: 2323
- Joined: 25.08.2021 18:15