Looking for a macro creating tool like: autohotkey for automating text file editing

Hi,
i am looking for a macro/scripting tool that allows me to automate repetitive tasks, similar to the windows tool: autohotkey.
Basically i just need it because i have to a bunch of text files, and the process is always the same (i use joe):

  • move text cursor to startpositon
  • type ‘<ENTER>’, ‘#’, ‘<CTRL>+x’
  • for (n=1; n<10; n++); do
    type ‘<ENTER>’, <SPACE>, ‘$n’, ‘<CTRL>+x’, ‘<CTRL>+x’
    done
  • type ‘<ENTER>’, ‘$n’, ‘<CTRL>+x’, ‘<CTRL>+x’, ‘<ENTER>’, ‘<ENTER>’

the last step would be copying the created text block and paste it to another file, but i would do that manually that is no problem.

Surly one could write a bash script for that too, but that would be unnecessary complicated if there is an alternative, because it is always the same keys to be pressed
only the start position changes.

probably use sed in a bash script

man sed for details

I think you should take care of those people here who have no Windows experiencce, let alone of a thing called “hotkey”.

I assume those things you describe that should be done, are supposed to be done within an editor. But you fail to explain which editor. Or do you mean that what you describe is what you should do in an editor in Windos (when yes, which one, or is there only one editor in Windows?).

Maybe you better describe what you would like to be done to such a file then those obscure keystrokes to let us guess what they do in an editor we may not know.

In other words, better describe the goal, not the means.

And yes, repetitive actions are normaly better programmed (often a bash script). For text editing within a script sed (stream editor) comes to my mind.

Thanks, i am only a beginner with sed but i found a solution using awk in a bash script.

edit: the editor iam using is called “joe”, but i did mentioned that in my post :slight_smile:
what i posted was some kind of pseudo code for the repetitive task i want to automate, independent from any editor, sorry if that was not clear enough.

I do understad you better now. I didn’t know of the existance of an editor named “joe” :frowning:

Very good you found an awk solution. Yes, sed and awk are powerfull tools.