Hi I made some functions to use with Python programming. I noticed however a problem with indentation. The functions are called from insert mode. An generic example is given below.
imap \sf <c-o>:call insert_text()<CR> function! insert_text() let pos = getpos('.') execute "normal! iSome text that can span several lines" call setpos(pos) endfunction 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" | and the text gets inserted like: print "Hello World" Some text that can span several lines In Python I cannot relay on = because it cannot know if I meant to go out an indentation level or not. 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? Thanks in advance Preben