Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

map "jk" to go to normal mode in vi-mode #31

Closed
divramod opened this issue Nov 6, 2019 · 7 comments
Closed

map "jk" to go to normal mode in vi-mode #31

divramod opened this issue Nov 6, 2019 · 7 comments
Labels
NYI/NewFeat Not yet implemented or New Feature question Question / Mis-usage

Comments

@divramod
Copy link

divramod commented Nov 6, 2019

Hey, thx for the awesome project!!!!

I like to use "jk" in vi-insert-mode to switch to normal mode.
Can you please help me to find the right mapping configuration?

thx in advance!!!

@akinomyoga
Copy link
Owner

Hi! Thank you very much for your feedback!

You can add the following line in ~/.blerc. (If you copied ble.sh/blerc file, I recommend to put it in the function blerc/vim-load-hook.)

ble-bind -m vi_imap -f 'j k' 'vi_imap/normal-mode'

If you want timeout after the key input j, please tell me. Currently the timeout is not supported in ble.sh, and therefore I have to take time (probably this weekend) to implement it.

@divramod
Copy link
Author

divramod commented Nov 7, 2019

hey @akinomyoga, thx for your fast reply!

this is exactly what i was looking for.

about the delay. i prefer to press both keys at the same time, because i have to do it the whole day and its faster. in vim i am using https://github.com/kana/vim-arpeggio to be able to use simultaneous keypresses. that really boosted some of my workflows.

so if you start doing something about that it would be nice, if i would be able to press both keys at the same time ;-)

thx again, great project. finally a reason i can completely switch to bash :-) the abbreviation feature and shell completion were the major reasons for me to stay with fish.

@divramod
Copy link
Author

divramod commented Nov 7, 2019

a thing i'd like to ask too is a mapping in normal and a mapping in insert mode to open the current command in vim. it would be nice to be able to open that command with vim -x.

i think there is a standard mapping for that but i never found the name for that feature. i had that running in fish and zsh too.

@divramod
Copy link
Author

divramod commented Nov 7, 2019

i added

ble-bind -m vi_imap -f 'j k' 'vi_imap/normal-mode'
ble-bind -m vi_imap -f 'k j' 'vi_imap/normal-mode'

now i can press both keys simultaneously :-)

@akinomyoga
Copy link
Owner

a thing i'd like to ask too is a mapping in normal and a mapping in insert mode to open the current command in vim. it would be nice to be able to open that command with vim -x.

Do you mean vim -X? Then, add the following settings:

VISUAL='vim -X'
ble-bind -m vi_imap -f '...' 'edit-and-execute-command'
ble-bind -m vi_nmap -f '...' 'vi-command/edit-and-execute-command'

@akinomyoga
Copy link
Owner

akinomyoga commented Nov 14, 2019

@divramod Hi! I implemented a timeout for key bindings. Could you try the latest commit 272344e to see if it works?

By the following example, you can trigger vi_imap/normal-mode only when the interval of j and k is less than 40 milliseconds or otherwise j and k have the original meaning.

ble-bind -m vi_imap -f 'j k' 'vi_imap/normal-mode'
ble-bind -m vi_imap -f 'k j' 'vi_imap/normal-mode'
ble-bind -m vi_imap -T j 40
ble-bind -m vi_imap -T k 40

I also added an extension library lib/vim-arpeggio.sh to make the above settings easier. Instead of the above settings, you can put the following settings. bleopt vim_arpeggio_timeoutlen is the setting for the timeout, i.e., the maximal interval of two keys to be interpreted as "simultaneous":

# blerc

function blerc/vim-arpeggio-hook {
  source "$_ble_base/lib/vim-arpeggio.sh"
  bleopt vim_arpeggio_timeoutlen=40

  ble/lib/vim-arpeggio.sh/bind -f jk 'vi_imap/normal-mode'
  # Here, you can add further simultaneous-key bindings...
  # usage: ble/lib/vim-arpeggio.sh/bind [-m keymap] -[fxc@s] kspecs command
}
blehook/eval-after-load keymap_vi blerc/vim-arpeggio-hook

@akinomyoga akinomyoga added the question Question / Mis-usage label Nov 15, 2019
@akinomyoga
Copy link
Owner

@divramod I close this issue. If you have any other questions, please feel free to open an issue anytime.

@akinomyoga akinomyoga added the NYI/NewFeat Not yet implemented or New Feature label May 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NYI/NewFeat Not yet implemented or New Feature question Question / Mis-usage
Projects
None yet
Development

No branches or pull requests

2 participants