weechat-vimode icon indicating copy to clipboard operation
weechat-vimode copied to clipboard

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

Open fghimis opened this issue 4 years ago • 7 comments

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:

  • :nmap <C-n> /buffer +1<CR>
  • :nmap <C-N> /buffer +1<CR>
  • :nmap ^N /buffer +1<CR>
  • :nmap C-N /buffer +1<CR>

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):

  • on pressing :nmap after setting the keybindings, I would not get the expected <C-n>, but only n or N or ^N.
  • also ^F and ^B don't seem to work with default settings, but ^U and ^D work fine

fghimis avatar May 31 '21 11:05 fghimis

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 :)

GermainZ avatar May 31 '21 11:05 GermainZ

Thanks, it works now as intended!

fghimis avatar May 31 '21 11:05 fghimis

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?

fghimis avatar May 31 '21 11:05 fghimis

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.

GermainZ avatar May 31 '21 12:05 GermainZ

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)?

fghimis avatar May 31 '21 12:05 fghimis

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

GermainZ avatar May 31 '21 12:05 GermainZ

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).

fghimis avatar May 31 '21 12:05 fghimis