Wednesday, June 18, 2014

Re: Key mapping not working in Insert mode of vim



On Wed, Jun 18, 2014 at 11:40 AM, Arup Rakshit <aruprakshit@rocketmail.com> wrote:
Hi,

I put the below key mappings in my ~/.vimrc file

:nmap <F6> :w<CR>:!ruby %<CR>
:imap <F6> :w<CR>:!ruby %<CR>

The mapping is working in *normal* mode, but not in *insert* mode. Can any one
help me to fix it. When I am pressing *F6* in *insert* mode, it is printing the
command itself in my program file as below :-

require 'csv'

p CSV.read("#{__dir__}/test.txt", 'rb', :col_sep => ':'a)
:w # <~~~ see this
:!ruby % # <~~~ see this

The above 2 are coming when I pressed *F6* in *insert* mode.


Try changing your mapping to:

:imap <F6> <ESC>:w<CR>:!ruby %<CR>

This is take you out of insert mode before saving your file and running it through ruby.


--
David
blog: http://www.traceback.org
twitter: http://twitter.com/dstanek

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