Live data from Hacker News

Writing Vim Plugins

stevelosh.com

1–10 of 21 posts

Re: Writing Vim Plugins

#2
Thanks Steve. Not only is your post on coming back to Vim (about plugins) excellent, but so is this. I've always wanted to write plugins but been lost. I would then write shell scripts and then call them from Vim. Hopefully, this will spur me to write plugins.

Re: Writing Vim Plugins

#4

Thanks Steve. Not only is your post on coming back to Vim (about plugins) excellent, but so is this. I've always wanted to write plugins but been lost. I would then write shell scripts and then call them from Vim. Hopefully, this will spur me to write plugins.

Thanks!

The easiest way to get started writing plugins is by:

* Writing little functions and mappings in your .vimrc.

* Looking at the code for a relatively small plugin someone else has made.

Give it a try! Vimscript is awful but making plugins is still fun.

Re: Writing Vim Plugins

#5
Nice article. I don't agree on the version numbering scheme though. In vim, version numbers are major.minor. Each plugin should define a variable g:loaded_PLUGIN_NAME that is set to the version number as integer (= 100 * major + minor). I.e. 0.1 is 1, 1.2 is 102, 2.12 is 212. This is important for dependency management or when users put code into after/plugin/name.vim that patches a specific version of a plugin.

Re: Writing Vim Plugins

#6

Thanks Steve. Not only is your post on coming back to Vim (about plugins) excellent, but so is this. I've always wanted to write plugins but been lost. I would then write shell scripts and then call them from Vim. Hopefully, this will spur me to write plugins.

Thanks! The easiest way to get started writing plugins is by: * Writing little functions and mappings in your .vimrc. * Looking at the code for a relatively small plugin someone else has made. Give it a try! Vimscript is awful but making plugins is still fun.

Your hard work is definitely much appreciated. I switched to Vim a week ago and Coming Home to Vim has been like a bible.

Re: Writing Vim Plugins

#7
Nice tips. I disagree on the unit test one though. I've been hacking on a vim+python based plugin (and learning python on the way) for past few days. When I started, I would fire vim up, test something and hit a non-actionable error (since I won't have the entire stack trace, nor could I use pdb.set_trace/attach debugger :().

Now I isolate vim as much as possible from core piece of code, and use a mock vim[1][2]. For every entrypoint into my python code from vim, I write a small unittest; run/debug it w/ nose and then just hook it to a vim key mapping. It reduced trial/error cycles significantly. -- [1] http://tadhg.com/wp/2010/02/16/some-vim-script-implementatio... [2] http://symlink.me/repositories/entry/blogit/testing/mock_vim...

Re: Writing Vim Plugins

#8
post #7

Nice tips. I disagree on the unit test one though. I've been hacking on a vim+python based plugin (and learning python on the way) for past few days. When I started, I would fire vim up, test something and hit a non-actionable error (since I won't have the entire stack trace, nor could I use pdb.set_trace/attach debugger :(). Now I isolate vim as much as possible from core piece of code, and use a mock vim[1][2]. For…

If I recall, tlib contains testing utilities. I haven't used them myself.

http://www.vim.org/scripts/script.php?script_id=1863

https://github.com/tomtom/tlib_vim

Re: Writing Vim Plugins

#9
I really like to write my plugins in Python, and Sublime Text 2 accommodates this perfectly. With the recent addition of Vintage (vi) Mode, I find myself using ST2 over vim more and more.

Re: Writing Vim Plugins

#10
post #9

I really like to write my plugins in Python, and Sublime Text 2 accommodates this perfectly. With the recent addition of Vintage (vi) Mode, I find myself using ST2 over vim more and more.

Maybe this is obvious but you can write vim plugins in python, end user vim simply must be compiled with python support. On my laptop running ubuntu, vim came with ruby and python support by default.
Post reply on HN