def feedkeys(keys, mode='n'):
 if (eval('mode()') == 'n'):
  if (keys == 'a'):
   cursor_pos = get_cursor_pos()
   cursor_pos[2] = (int(cursor_pos[2]) + 1)
   set_cursor_from_pos(cursor_pos)
  if (keys in 'ai'):
   keys = 'startinsert'
 if (keys == 'startinsert'):
  command('startinsert')
 else:
  command((as_unicode('call feedkeys("%s", "%s")') % (keys, mode)))

def feedkeys ( keys , mode = 'n' ) : if ( eval ( 'mode()' ) == 'n' ) : if ( keys == 'a' ) : cursor_pos = get_cursor_pos ( ) cursor_pos [ 2 ] = ( int ( cursor_pos [ 2 ] ) + 1 ) set_cursor_from_pos ( cursor_pos ) if ( keys in 'ai' ) : keys = 'startinsert' if ( keys == 'startinsert' ) : command ( 'startinsert' ) else : command ( ( as_unicode ( 'call feedkeys("%s", "%s")' ) % ( keys , mode ) ) )
wrapper around vims feedkeys function .