From fc09ffb34a6272eaaa572c8609ad3ff61c4191dc Mon Sep 17 00:00:00 2001 From: Slava Date: Mon, 19 May 2025 17:22:06 +0500 Subject: [PATCH] UNICODE_MODE_VIM: switch from `i_CTRL-V u` to `i_CTRL-V U` --- docs/features/unicode.md | 8 ++++---- docs/keycodes.md | 2 +- quantum/unicode/unicode.c | 14 ++++++++++++-- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/docs/features/unicode.md b/docs/features/unicode.md index 0ff370feba9..e28db9c564b 100644 --- a/docs/features/unicode.md +++ b/docs/features/unicode.md @@ -207,7 +207,7 @@ Not currently implemented. If you're a BSD user and want to contribute support f **Mode Name:** `UNICODE_MODE_VIM` -Vim supports input of unicode characters up to `U+FFFF`. To insert a unicode character, press `ctrl+v u` in insert mode. For more informaton, see `:h utf-8-typing`. +Vim supports input of all the unicode characters. For more information check `:h i_CTRL-V_digit`. In Vim unicode mode, keyboard sends `ctrl+v`, `shift+u`, and then digits of the unicode point. ::::: @@ -225,8 +225,8 @@ Vim supports input of unicode characters up to `U+FFFF`. To insert a unicode cha |`QK_UNICODE_MODE_WINDOWS` |`UC_WIN` |Switch to Windows input | |`QK_UNICODE_MODE_BSD` |`UC_BSD` |Switch to BSD input (not implemented) | |`QK_UNICODE_MODE_WINCOMPOSE`|`UC_WINC`|Switch to Windows input using WinCompose | -|`QK_UNICODE_MODE_EMACS` |`UC_EMAC`|Switch to emacs input (`C-x-8 RET`) | -|`QK_UNICODE_MODE_VIM` |`UC_VIM`|Switch to vim input (`CTRL-V u`) | +|`QK_UNICODE_MODE_EMACS` |`UC_EMAC`|Switch to Emacs input (`C-x-8 RET`) | +|`QK_UNICODE_MODE_VIM` |`UC_VIM`|Switch to Vim input (`CTRL-V U`) | ## API {#api} @@ -294,7 +294,7 @@ Begin the Unicode input sequence. The exact behavior depends on the currently se - **WinCompose**: Tap `UNICODE_KEY_WINC`, then U - **HexNumpad**: Hold Left Alt, then tap Numpad + - **Emacs**: Tap Ctrl+X, then 8, then Enter - - **Vim**: Tap Ctrl+V, then u + - **Vim**: Tap Ctrl+V, then Shift+U This function is weakly defined, and can be overridden in user code. diff --git a/docs/keycodes.md b/docs/keycodes.md index 82333fe596b..def002f9c10 100644 --- a/docs/keycodes.md +++ b/docs/keycodes.md @@ -903,4 +903,4 @@ See also: [Unicode Support](features/unicode) |`QK_UNICODE_MODE_BSD` |`UC_BSD` |Switch to BSD input (not implemented) | |`QK_UNICODE_MODE_WINCOMPOSE`|`UC_WINC`|Switch to Windows input using WinCompose | |`QK_UNICODE_MODE_EMACS` |`UC_EMAC`|Switch to Emacs input (`C-x-8 RET`) | -|`QK_UNICODE_MODE_VIM` |`UC_VIM` |Switch to Vim input (`i_CTRL-V u`) | +|`QK_UNICODE_MODE_VIM` |`UC_VIM` |Switch to Vim input (`i_CTRL-V U`) | diff --git a/quantum/unicode/unicode.c b/quantum/unicode/unicode.c index 9a50abdb944..a1407099838 100644 --- a/quantum/unicode/unicode.c +++ b/quantum/unicode/unicode.c @@ -258,7 +258,7 @@ __attribute__((weak)) void unicode_input_start(void) { break; case UNICODE_MODE_VIM: tap_code16(LCTL(KC_V)); - tap_code16(KC_U); + tap_code16(LSFT(KC_U)); break; } @@ -289,7 +289,7 @@ __attribute__((weak)) void unicode_input_finish(void) { tap_code16(KC_ENTER); break; case UNICODE_MODE_VIM: - // It finishes by itself when 4 hex digits received + // It finishes by itself when enough hex digits received break; } @@ -350,6 +350,16 @@ void register_hex(uint16_t hex) { } void register_hex32(uint32_t hex) { + // In vim, `i_CTRL-V U` waits for exactly 8 digits, so we send them all + // @see `:h i_CTRL-V_digit` + if (unicode_config.input_mode == UNICODE_MODE_VIM) { + for (int i = 7; i >= 0; i--) { + uint8_t digit = ((hex >> (i * 4)) & 0xF); + send_nibble(digit); + } + return; + } + bool first_digit = true; bool needs_leading_zero = (unicode_config.input_mode == UNICODE_MODE_WINCOMPOSE); for (int i = 7; i >= 0; i--) {