Wednesday, April 25, 2018

Re: I'd emulate Ctrl-Space keypress and CLI with Esc using map

On 04/25/18 16:46, Tony Mechelynck-san wrote:
> On Wed, Apr 25, 2018 at 6:15 AM, Takao Fujiwara <fujiwara@redhat.com> wrote:
>> I'd like to create a new shortcut key of `F4` to send Esc to vim but
>> Ctrl-space to xterm, gnome-terminal instead of vim.
>>
>> Seems the command `imap <F4> <Esc> :call feedkeys("\<C-Space>")<CR>` does
>> not send Ctrl-Space.
>>
>> Do you have any ideas?
>>
>> I also tried the two commands:
>>
>> nmap <silent> <F4> :!ibus engine anthy<CR>a
>> imap <silent> <F5> <Esc>:!ibus engine xkb:us::eng<CR><CR>
>>
>> They work if I run each command directly in vim buffer. But they do not work
>> if I save them in vimrc.
>>
>> Do you have any ideas?
>
> See :help CTRL-\_CTRL-G
>
> N.B.
> 1. You can use a single {lhs} for nmap and imap, Vim won't mix them up.
> 2. (about the RTFM above) 'insertmode' should only be set in the
> so-called "easy Vim" (actually a Notepad look-alike :-P )

Thank you. My {lhs} is <F4> or <F5> which are single keys.
From your reply, I guess I should not add space characters in the command line.

I noticed my vim does not provide `:help CTRL-\_CTRL-G` in Fedora.
And seems vim-minimal package does not provide the full supports of vimrc.

After I installed vim-enhanced package, my vim can work with $HOME/.vimrc of the following content:

nmap <silent> <F4> :!ibus engine anthy<CR>a
imap <silent> <F5> <Esc>:!ibus engine xkb:us::eng<CR><CR

However feedkeys() still does not work.

imap <F5> <C-\><C-G>:call feedkeys("\<C-Space>")<CR>

When I press F5 key in the insert mode, I'd change the mode to the normal mode and send Ctrl-space key to xterm or gnome-terminal but not vim.
But the actual result is, <C-/><C-G> or <Esc> works but feedkeys() does not forward Ctrl-space to my input method.

Do you have any ideas?


>
> Best regards,
> Tony.
>

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: