GermainZ / weechat-vimode

A WeeChat script that adds vi-like modes, commands and keybindings.
GNU General Public License v3.0
265 stars 28 forks source link

Pressing <Esc> should not move the cursor if we're already in Normal mode #92

Open fghimis opened 3 years ago

fghimis commented 3 years ago

I am trying to reuse the normal keybindings for switching channels.

Normally, when pressing Ctrl+n I will advance one channel and Ctrl+p will go back. Currently, this works only one I'm in Insert mode. When I switch to Normal mode it stops working.

I have tried the following nmaps:

And none worked. I'm using the latest script on https://weechat.org/scripts/source/vimode.py.html/ : Version: 0.8.1

More info (I don't know if it helps):

GermainZ commented 3 years ago

Please try the script from this repo, that should work. (The versions are a bit messed up, 0.8/0.8.1 from the weechat repo are actually 0.7 in this repo).

I will submit a PR to update the weechat script when I have some time :)

fghimis commented 3 years ago

Thanks, it works now as intended!

fghimis commented 3 years ago

Another question, not to open another issue, but when I'm in normal mode and I press \<Esc> I would get back 1 character (like backspace). Can that be fixed?

GermainZ commented 3 years ago

That's intended behavior (similar to vim). You can edit the source code if you don't like it, though. Specifically, you can comment out/remove this line.

fghimis commented 3 years ago

No, I mean when I'm in Insert mode and i press Esc it's normal to go back 1 character. But I am in Normal mode, and I press Esc again, and I go back 1 character (similar to pressing h in Normal mode). Shouldn't it do nothing (already being in Normal mode)?

GermainZ commented 3 years ago

Oh yeah, I'll reopen the issue and rename it so I don't forget about it. Thanks!

fghimis commented 3 years ago

Oh and something else (it may be related to mode switching): Pressing \<Esc> to cancel Ex mode will erase current line. Steps to reproduce: 1) Enter insert mode, write: "some text here" 2) Press Esc (enter normal mode) 3) Press : (enter ex mode) 4) Change your mind and press Esc to go back in normal mode 5) "some text here" is gone, only : remains

On further checking, the text is there if I press undo (u) and then redo (C-R).