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

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Takao Fujiwara-2
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?

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

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

Tony Mechelynck
On Wed, Apr 25, 2018 at 6:15 AM, Takao Fujiwara <[hidden email]> 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 )

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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

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

Takao Fujiwara
On 04/25/18 16:46, Tony Mechelynck-san wrote:

> On Wed, Apr 25, 2018 at 6:15 AM, Takao Fujiwara <[hidden email]> 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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

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

Tony Mechelynck
It surprises me that your Vim apparently doesn't know about Ctrl-\
Ctrl-G. Which Vim version is that? (Vim 8.0 was released 12-Sep-2016,
and the latest patchlevel is 8.0.1765 as of this writing.) To compile
your own Vim on Unix/Linux, see
http://users.skynet.be/antoine.mechelynck/vim/compunix.htm and some of
the pages linked from there. If you install your own-compiled Vim
under its default /usr/local/ directory, it will normally live happily
together in the Vim version(s) from your distro, and it will be
earlier in the $PATH.

To change from Insert mode to Normal mode for just one command (which
may be several keys e.g. 3j to go 3 lines down, or even a whole
ex-command from : to <CR>) there is also CTRL-O, see :help i_CTRL-O
(IIRC that one existed already in Vim 6 and probably before, if the
latest Vim on RedHat/Fedora doesn't know about it it might be time to
switch to another distro.)

vim-minimal is (as its name says) a minimal Vim, usually a Tiny build;
it may be packaged under the executable name "vi" and it hasn't got
all the bells and whistles in even a "normal" Vim. vim-enhanced or
even vim-gui (or all three, IIRC they can be installed together) are
usually better choices for the "serious" Vim user.

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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

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

Takao Fujiwara
Sorry, I may confuse you.
Fedora 28 vim is 8.0.1704 which is built by distribution not mine.
vim-minimal does not send Ctrl-\ and Ctrl-G but vim-enhanced can send them.
I didn't notice vim-minimal does not support .vimrc fully.
Now I use vim-enhanced and that problem is fixed.

vim-minimal is built with:
%configure --prefix=%{_prefix} --with-features=small --with-x=no \
   --enable-multibyte \
   --disable-netbeans \
%if %{WITH_SELINUX}
   --enable-selinux \
%else
   --disable-selinux \
%endif
   --disable-pythoninterp --disable-perlinterp --disable-tclinterp \
   --with-tlib=ncurses --enable-gui=no --disable-gpm --exec-prefix=/ \
   --with-compiledby="<[hidden email]>" \
   --with-modified-by="<[hidden email]>"

vim-enhanced is built with:
configure --with-features=huge \
   --enable-pythoninterp=dynamic \
   --enable-python3interp=dynamic \
   --enable-perlinterp=dynamic \
   --disable-tclinterp --with-x=yes \
   --enable-xim --enable-multibyte \
   --with-tlib=ncurses \
   --disable-gtk3-check \
   --enable-gtk3-check --enable-gui=gtk3 \
   --with-compiledby="<[hidden email]>" --enable-cscope \
   --with-modified-by="<[hidden email]>" \
%if "%{withnetbeans}" == "1"
   --enable-netbeans \
%else
   --disable-netbeans \
%endif
%if %{WITH_SELINUX}
   --enable-selinux \
%else
   --disable-selinux \
%endif
%if "%{withruby}" == "1"
   --enable-rubyinterp=dynamic \
%else
   --disable-rubyinterp \
%endif
%if "%{withlua}" == "1"
   --enable-luainterp=dynamic \
%else
   --disable-luainterp \
%endif
   --enable-termtruecolor

Now my another problem is that I cannot send Ctrl-Space key to xterm or gnome-terminal but not vim.
I tried:

nmap <F4> <C-Space>

and

nmap <F4> :call feedkeys("\<C-Space>")<CR>

but gnome-terminal receives F4 key only with either nmap when I debugged gnome-terminal.

I tried 8.0.1704 of Fedora 28 and 8.0.1766 of Fedora 29 but vim, vimx, gvim failed to receive the key events.
I thought I might mistake the syntax.
Or do you mean the syntax is correct and you can send Ctrl-Space key with the above nmap?

Thanks

On 04/26/18 22:48, Tony Mechelynck-san wrote:

> It surprises me that your Vim apparently doesn't know about Ctrl-\
> Ctrl-G. Which Vim version is that? (Vim 8.0 was released 12-Sep-2016,
> and the latest patchlevel is 8.0.1765 as of this writing.) To compile
> your own Vim on Unix/Linux, see
> http://users.skynet.be/antoine.mechelynck/vim/compunix.htm and some of
> the pages linked from there. If you install your own-compiled Vim
> under its default /usr/local/ directory, it will normally live happily
> together in the Vim version(s) from your distro, and it will be
> earlier in the $PATH.
>
> To change from Insert mode to Normal mode for just one command (which
> may be several keys e.g. 3j to go 3 lines down, or even a whole
> ex-command from : to <CR>) there is also CTRL-O, see :help i_CTRL-O
> (IIRC that one existed already in Vim 6 and probably before, if the
> latest Vim on RedHat/Fedora doesn't know about it it might be time to
> switch to another distro.)
>
> vim-minimal is (as its name says) a minimal Vim, usually a Tiny build;
> it may be packaged under the executable name "vi" and it hasn't got
> all the bells and whistles in even a "normal" Vim. vim-enhanced or
> even vim-gui (or all three, IIRC they can be installed together) are
> usually better choices for the "serious" Vim user.
>
> 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 [hidden email].
For more options, visit https://groups.google.com/d/optout.