test if insert mode
How do I implement a conditional to test if in insert or normal mode? Thanks -- Eric Smith
Re: test if insert mode
On 7/18/06, Eric Smith <[EMAIL PROTECTED]> wrote: How do I implement a conditional to test if in insert or normal mode? There is funciton mode(), but it might not work for you. But see cautionary sentence at the end of :help mode(). People reported problems. if mode() == 'i' " in insert mode else if mode() == 'n' " in normal mode endif See :help mode() If you experience problems, then tell us what are you trying to do, like, for what you are trying to use it. Yakov
Re: test if insert mode
On Tue, Jul 18, 2006 at 11:49:52AM +0200, Eric Smith wrote: > How do I implement a conditional to test if in insert or normal mode? > > Thanks If I am doing anything at all complicated, I use a function: :map :call Foo() If I want to do something slightly different depending on the mode, I add a flag to the argument list: :nmap :call Foo('n') :imap :call Foo('i') function! Foo(mode) if a:mode == 'n' " set up for Normal mode elseif a:mode == 'i' " set up for Insert mode else " oops! return endif " lots more stuff endfun HTH --Benji Fisher