Better text editor?

OOOPS! didn’t error check - should be 7:07 pm (and would be with the right tool). Scripting should be able to handle it, a few search/replaces - a few deletes to line things up as records - and a column swap at the end…

I’ve done this kind of thing lots - but I would appreciate it being 10 minutes!

It would take me maybe 20 minutes to write an Awk script to do it. With practice, I guess 10 minutes is achievable.

Writing the script for awk to do it would be (at best) 20 hours for me! And the constant restoring of backups of the original data after ‘testing’ would be wearing on the nvme drive too! Now you can see why a simple recording macro ability would be optimum…

test sequence of keystrokes - 1 minute
record sequence - 1 minute
run and test result - 2 minutes
run 5 search/replace - 2 minutes
test result - 3-4 minutes

that’s the 10 minutes I’d expect :grin:

You can probably use XMacro with any text editor.

Or even more simply, with xdotool.

1 Like

Some alternatives if you are interested:

2 Likes

Here, I figured it out. A quick demo of a macro:

  1. Type 123456789 in Kate (or any other text editor).
  2. Press F4 to open Konsole embedded in Kate (or open any other terminal emulator).
  3. Run this command in the terminal:
sleep 3; for x in $(seq 9); do xdotool key Right a; done 
  1. In the next 3 seconds click in the main Kate window and position the cursor in front of the number 1.
  2. Wait 3 seconds.
  3. The text is now:
1a2a3a4a5a6a7a8a9a

What the macro did was emulate the following keypresses:

AAAAAAAAA

Of course, this could have been done with a simple regex search and replace, but the point is to demonstrate how macros can be programmed in Bash for any Xorg window.

You can even make a little script like this:

#!/bin/sh
if [ -z "$1" ]; then
  printf "Usage:\n  macro n_repeats \"key sequence\"\n\ne.g. macro 10 \"a shift+b c\"\n"
  exit
fi

printf "Starting in 3...";   sleep 1
printf "\rStarting in 2..."; sleep 1
printf "\rStarting in 1..."; sleep 1
printf "\rStart!          \n"

for x in $(seq $1); do xdotool key $2; done

Here is a video demonstration of it:

There, you can now have macros in any program, and you can go back to using your lame text editor and forget about Kate. :wink:

2 Likes

https://www.geany.org/manual/#column-mode-editing-rectangular-selections

1 Like

Actually, I looked through it, and I got the impression that it can edit IN columns, but not handle columnar block moves. However - this xdotool capability can be made to make an acceptable substitute if it can handle key modifiers as well as keys (shift-arrow as needed, cut, reposition, paste - next line) if it is needed. The rest is more needed anyway.

I’ll be trying out this in Code (VsCode) my main editor - or even in Featherpad for simplicity. Thanks to all who chimed in - and hopefully this will work (and save some time on this one and more).

VsCode has lots of features and documentation as well. Sometimes I find it a bit challenging to find the documentation I need… :wink:

1 Like

Yes, it can handle modifiers.

In Kate:

stupid example

In Terminal, focus on Kate after executing:

~🐸 sleep 3; xdotool key Home Shift+Ctrl+Right Ctrl+x End space Ctrl+v

Kate now contains:

example stupid
2 Likes

I cheat with vsCode - I have other people helping with setting it up! I have it with extensions for lua and conky for example - and syntax highlighting for both as well! Certainly a lot of features, but no macros I could find… :slightly_frowning_face:

What command is this?
Thanks

pactree – a simple dependency tree viewer.

Print the dependency tree for a package:

pactree package

Print what packages depend on a specific package:

pactree -r package 

More info:

man pactree
1 Like

I think Freebird, what Kresimir is trying to say, just embrace KDE and Kate. We will assimilate you…cheerfully? :slight_smile:

2 Likes

That is exactly what happened to me. Especially Kate and Dolphin. I use single click and in Dolphin when the cursor is hovered over the upper left corner of a file, the + or - appears to add or delete from selected files. That is great for my work flow. I won’t even get into how good Kate is.

Pudge

1 Like

Dolphin is a great file manager, don’t get me wrong, but I prefer to do my file managing from the terminal. The best thing about Dolphin, in my opinion, is that it has embedded Konsole in it (opened with F4) that automatically cds when you open a folder. So if I use Dolphin, I use it like a variant of Konsole tailored specifically for file management.

Kate also has the same feature, the embedded Konsole, which is great for compiling code, running batch jobs, executing scripts, etc… It’s lovely how those three programs integrate.

1 Like

The only thing I miss in Kate is Geany’s quick find input field; used that all the time. Now in Kate I have become used to CTRL+F. First world problems.

1 Like

I don’t see where it has any advantage over XFCE equivalent - Thunar does the cd thing for the terminal - and my editor does the terminal things with choice of terminal…

Ah well - to each… :grin:

1 Like

Thank you!

Is there some trick to making xdotool work? Everything I try gets this result

(symbol) No such key name 'home_l'. Ignoring it.
(symbol) No such key name 'home'. Ignoring it.
(symbol) No such key name 'XK_Home'. Ignoring it.

Not terribly effective…so far!