2

I am looking for a terminal command or script or program which moves the text cursor in whichever text field currently has focus. Something like:

move_cursor 1

which would move the cursor one column to the right. The reason is that I would like to define keyboard shortcuts which execute this command so I can have keyboard control of the cursor.

Since I am using this with keyboard shortcuts, keyboard event solutions won't work, for example

xdotool key --clearmodifiers Right

in principle does what I am asking, but since the command will be executed when other keys are depressed, it doesn't really work well.

The behavior I am looking for is similar to the GTK+ Keybinding Theme setting (org.gnome.desktop.interface.gtk-key-theme) which can be set to 'Emacs' so that, for example, ctrl-f moves the cursor right one column, ctrl-b moves back one column, ctrl-d deletes the character to the right of the cursor, etc. I just want different keybindings.

7
  • 1
    Hi, you want to achieve this while Emacs option is on or off?
    – PRATAP
    May 7, 2019 at 7:13
  • Preferably off, unless I can just replace the emacs keybindings with my own.
    – Doeke
    May 7, 2019 at 7:27
  • 1
    Ok, and what are the exact key combination you want to use for moving the cursor to right and left?
    – PRATAP
    May 7, 2019 at 7:30
  • 1
    I Just made a custom shortcut with Alt+a xdotool sleep 0.3 key Right it worked.. but i know sleep time is a big negative here..
    – PRATAP
    May 7, 2019 at 7:34
  • I've remapped capslock to the hyper key, and the key combination would be '<hyper>+f'
    – Doeke
    May 7, 2019 at 7:39

1 Answer 1

3

I've found a solution using Autokey. Install and open the autokey GUI and create a new phrase, name it whatever you want. In the main field, enter the system key combination that achieves your goal, then set your hotkey using the button at the bottom of the GUI. For example, I've mapped my capslock key to the hyper key using xmodmap, so my shortcuts are as follows...

Some examples:

Move cursor right: <right> (shortcut: <hyper>+f)

Move cursor left: <left> (shortcut: <hyper>+b)

Delete next word: <ctrl>+<delete> (shortcut: <hyper>+<shift>+d)

Move to beginning of line: <home> (shortcut: <hyper>+a)

Delete line to the right of the cursor: <ctrl>+<end><delete> (shortcut: <hyper>+k)

Use your imagination!

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .