Monday, November 30, 2009

Prevent from entering to insert mode before finishing mapping

As per subject, is there a way to prevent from entering to insert mode
before finishing mapping?

Below is my script. There are three comands that I want to execute for
one mapping. When I type command dw or pw, it works as what I want,
because it stays in normal mode. However, when I type command cw, it
will enter to insert mode, and then type ":exe DoCommand()<CR>:call
DoSomethingElse()<CR>".

So, I guess that it enters insertmode after finishing first command.
Is there a way to make it finish the three comands first, and then go
to insert mode?
Any advice is really appreciated. Thank you.

onoremap w :<C-U><CR>:exe DoCommand()<CR>:call DoSomethingElse()<CR>

function! DoCommand() range
return 'normal! d2w'
endfunction

function! DoSomethingElse()
echo 'dummy'
endfunction

Note: I intentionally oversimplify the DoCommand() function.

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php

No comments: