amoffat/snake

Compare to Vim’s built-in Python scripting support

roryokane opened this issue · 1 comments

Vim already has built-in support for Python scripting, when compiled with the +python feature. People who find this repository might not know that. You should mention it so that people know what the options are, and describe the differences.

I presume that these are some differences:

  • Snake requires an external python program to be installed, while built-in support requires Vim to be compiled with +python. Each prerequisite might be easier to satisfy on some systems and harder on others.
  • Snake provides a different (better?) Python API from the built-in Python API.

If you didn’t know about Vim’s built-in Python support, here is a good tutorial. And here is 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)

Thanks @roryokane. Snake only requires built-in Vim Python support via +python to work, and it's only an extension of what's there already. If you want to open a PR with some documentation about "How Snake works with Vim" (or something along those lines), we can take a look at merging it in.