Ask HN: What kind of sample Vim plugin should I build in LVSTHW?

33 points by stevelosh ↗ HN
I've been working on Learn Vimscript the Hard Way[1] and I've been making pretty good progress.

I need advice on the third section of the book. In the third part I want to walk through writing a Vim plugin from scratch. I want it to be something significant that touches a lot of aspects of writing Vim plugins, but I don't want to just make something arbitrary that no one would ever use.

Right now I'm leaning toward writing a plugin for a language that doesn't already have one: Potion[2]. A plugin for a language can touch on syntax, folding, compilers, ft-specific mappings, and tons more.

If you have ideas for a good example plugin that's not too complex (it has to fit into one third of an already short book) but touches lots of aspects of Vimscript and isn't completely contrived, I'd love to hear them.

[Learn Vimscript the Hard Way]: http://learnvimscriptthehardway.stevelosh.com/

[Potion]: http://www.runciter.net/potion/

11 comments

[ 5.0 ms ] story [ 39.2 ms ] thread
What about HTML Indentation that Doesn’t Suck, as you wrote in "Coming home to VIM?"
Ah, I finally figured that out actually. There were 2 problems:

* Some of the elements aren't considered for indentation, but they should be. You just have the edit the HTML syntax that comes with Vim to add them to the list.

* I was actually using Django templates, and the tags weren't being considered for indentation. I wrote a little syntax file for those based on the ERB one: https://bitbucket.org/sjl/dotfiles/src/1b6ffba66e9f/vim/bund...

You should update your post with this information unless it's there but I didn't notice it.
I was going suggest something similar to fugitive for Mercurial, but it looks like you've already considered that in 'Coming home to Vim.'

I think you're correct in how many different facets you can show through a language plugin, so I vote for that.

Yeah, and Fugitive for Mercurial would be really big and twisty. I want something fairly easy but still useful/illustrative.
I don't have a specific idea at the moment, but...

I've often wondered why emacs seems to have these plugins and modes that make one want to learn emacs, and vim doesn't. For instance, org mode. I don't think there something inherent to emacs that makes a mode like that work better there, and I'd love to see info on how to write plugins like that.

In fact, perhaps a simple org mode clone would be a good example project; it would certainly touch a lot of vimscript.

https://github.com/jceb/vim-orgmode

I think part of the reason emacs has better plugins is that it has real support for talking to external processes, where Vim has a bunch of ugly hacks that barely work.

Emacs users have embraced the "do everything in Emacs" philosophy whereas Vim users tend to use a specific tool for a specific job.

Something I've always wanted but haven't got round to creating is a command that would convert from camel case to pascal case to uppercase with underscores.

It would be awesome if you were able to yank text in one case and it would paste in a different case if it was being pasted on top of exiting text.

for example if you had the code: #define USER_NAME_LEN const int userNameId; class UserName { };

if you did a search and replace for userName to replace with clientName it would update all cases correctly.