On Tue, Aug 08, 2006 at 05:05:15AM +0200, Preben Randhol wrote:
> 
>       imap \sf <c-o>:call insert_text()<CR>
> 
> Now, say I have typed:
> 
>       def some_func():
>               '''Some func'''
>               
>               print "Hello World"
> 
>               |
>       
> (| = cursor position)
> 
> if I now use the \sf mapping then the cursor moves to:
> 
>               print "Hello World"
> 
>       |

     It is not clear from what you have written:  if the "def" line is
indented, does the cursor get indented too?  It does not for me, so I
will assume that all the indent was removed and that you indented the
whole example.

     This behavior is (almost) explained under

:help 'autoindent'

I say "almost" because <C-O> is not listed along with <Esc> and <CR> as
one of the keys that will remove all indent if typed on an "empty" line.

> I have mapped the function in this way:
> 
>       imap \sf x<c-o>x<c-o>:call insert_text()<CR>
>       
> which solves the problem as the cursor doesn't jump out, but isn't
> there a cleaner way to do this?

     This is slightly simpler:

        imap \sf x<BS><c-o>:call insert_text()<CR>

HTH                                     --Benji Fisher

Reply via email to