zyedidia / micro

A modern and intuitive terminal-based text editor
https://micro-editor.github.io
MIT License
24.47k stars 1.16k forks source link

Problems with key bindings (using KiTTY) #3084

Closed Heart1010 closed 7 months ago

Heart1010 commented 7 months ago

Description of the problem or steps to reproduce

I have problems with some of the standard key bindings - e.g. Ctrl+f to initiate the search is working but when I then try to find the next occurence by pressing Ctrl+n nothing happens (same with Ctrl+p).

I then used showkey to find out corresponding escape sequence for a given key combo.

# showkey -a

Drücken Sie eine Taste - Strg+D beendet das Programm

^N       14 0016 0x0e
^P       16 0020 0x10

So I get ^N for Ctrl+n and ^P for Ctrl+p but whe I use that in my ~/.config/micro/bindings.json

# cat ~/.config/micro/bindings.json
{
    "Alt-/": "lua:comment.comment",
    "^N": "FindNext",
    "^P": "FindPrevious",
    "AltCtrlSpace": "command:palettero",
    "CtrlSpace": "command:palettero",
    "CtrlUnderscore": "lua:comment.comment"
}

micro gives me an error.

# micro /etc/exim4/exim4.conf.template
^N is not a bindable event

Press enter to continue
^P is not a bindable event

Press enter to continue
root@cp:~# micro ~/.config/micro/bindings.json
^N is not a bindable event

Press enter to continue
^P is not a bindable event

Press enter to continue

So how can I find the correct binding I have to use for e.g. Ctrl+n and Ctrl+p?

Thanks

Specifications

Version: 2.0.13 Commit hash: 68d88b57 Compiled on October 21, 2023

OS: Debian 12

Terminal: KiTTY

dustdfg commented 7 months ago
  1. ^N isn't correct syntax for micro. You need to use Ctrl-n
  2. About search and Ctrl-f. I am not sure but it seems to me you didn't press Enter at the end. 2.1. You press Ctrl-f to get into "search mode" 2.2. You type what you need (it will look Find (regex): <your_search>) 2.3. While you still in "search mode" Ctrl-n and Ctrl-p will iterate through your search history 2.4. Press eEnter to return to normal mode 2.5. Press Ctrl-n or Ctrl-p
Heart1010 commented 7 months ago

regarding 2: yes, everything clear... but regarding 1: for sure I've also tried to delete every entry in bindings.conf regarding FindNext and FindPrevious so the default Ctrl-n and Ctrl-p setting should be there - don't work. I've also tried to explicitly set Ctrl-n and Ctrl-p in the bindings.conf - don't work also.

So my problem is - when I press Ctrl-n or Ctrl-p while I'm in search mode NOTHING HAPPENS

Heart1010 commented 7 months ago
  1. ^N isn't correct syntax for micro. You need to use Ctrl-n
  2. About search and Ctrl-f. I am not sure but it seems to me you didn't press Enter at the end. 2.1. You press Ctrl-f to get into "search mode" 2.2. You type what you need (it will look Find (regex): <your_search>) 2.3. While you still in "search mode" Ctrl-n and Ctrl-p will iterate through your search history 2.4. Press eEnter to return to normal mode 2.5. Press Ctrl-n or Ctrl-p

Ok - forget what I've told above. You're right!!!!

I've missed that 2.4 enter press - after that enter press Ctrl-n and Ctrl-p works as desired 👍

(I didn't have any search pattern from the past so my Ctrl-n / Ctrl-p presses while still in search mode didn't change anything visually for me.)