Wednesday, June 18, 2014

Re: Key mapping not working in Insert mode of vim

On Wednesday, June 18, 2014 3:05:07 PM UTC-5, Ethan Hereth wrote:
>
> According to the following vim.wikia post you should be able to use
>
> Ctrl-O but I cannot seem to make it work.
>
>
>
> http://vim.wikia.com/wiki/Use_Ctrl-O_instead_of_Esc_in_insert_mode_mappings
>
>
> [SNIP]
>
> If I run the command ':!python %' (without the quotes, I never know if
>
> I really need to clarify that or not!) the python snippet runs like
>
> I'd expect to and I get the file foo.txt. However, when I define
>
> ':inoremap <F6> <C-o>!python %<CR>' and attempt to use it nothing
>
> seems to happen.

<C-o> in insert mode will execute one NORMAL MODE command, then return you to insert mode.

Think about how you would do this from normal mode and you get your answer.

!python %<CR> in normal mode won't do what you want (if it does anything).

But, pressing ':' first will do what you want.

The following mapping should work:

:inoremap <F6> <C-o>:!python %<CR>

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

Post a Comment