1. 9
  1.  

  2. 3

    If your Vim version was compiled with +python, you can just use Vim’s built-in Python support. Here is a good tutorial, and the Python API docs. An example script:

    insertbuffername.vim
    if !has('python')
        finish
    endif
    
    function! InsertBufferName()
        pyfile insertbuffername.py
    endfunc
    
    command! InsertBufferName call InsertBufferName()
    
    insertbuffername.py
    def normal(str):
        vim.command("normal! "+str)
    
    buffer = vim.current.buffer
    normal("i" + buffer.name)