
Learn Vimscript the Hard Way - stevelosh
http://learnvimscriptthehardway.stevelosh.com/?published
======
dewitt
Good stuff. And I was curious after seeing this if "Learn ... the Hard Way"
was a brand that that Zed Shaw had trademarked or otherwise intended to keep
exclusive. (Not that there necessarily would have been anything wrong with
that, but still curious.)

But to my surprise, Shaw not only isn't proprietary about the brand, it looks
like he is going out of his way to help other people appropriate it:

<https://gitorious.org/learn-x-the-hard-way>

_"This is a skeleton LaTeX project that makes it easier to start working on a
“Learn X The Hard Way” book. You simply clone this repository, change a few
base files, and then you can start writing. It will also come with a small
“meta book” that gives you advice for writing and publishing your book."_

Very cool. While it seems that Steve Losh didn't use the actual templates
above (he picked markdown instead of rst), it's neat that the overall style
itself is designed to be reusable.

Best of luck with the new book!

~~~
masklinn
> But to my surprise, Shaw not only isn't proprietary about the brand, it
> looks like he is going out of his way to help other people appropriate it

I'm not sure why you were surprised, as far as I've seen Zed has generally
gone out of his way to be a helpful guy. He's a bit raw and he doesn't like
assholes, but he really doesn't deserve the bad rap he got in some circles.
Most of it really comes from the aforementioned assholes, who happen to be
more PR-savvy than him.

~~~
zedshaw
Uh, yeah they're not more PR savvy than I am. The vast majority of people that
know about me think more like you do, and only a few mostly Rubyists think of
me as some kind of boogeyman, which I also tend to cultivate since it's damn
funny.

~~~
dewitt
FWIW, I certainly didn't intend any disrespect (sorry that the person above
jumped to that conclusion). I meant it more in the sense of a happy surprise,
given that you had already freely distributed the content, also making the
brand itself available was really going above and beyond.

------
dewitt
Also, Steve, would you consider using the Creative Commons Attribution-
NoDerivs 3.0 license instead of a homemade license? I believe the CC BY-ND
conveys most* of the same things you intended with your license, but it has
the advantage of being pre-vetted by layers everywhere and the CC terms are
very well understood (thus encouraging reuse in the ways you want, and
ostensibly easier to enforce for the things you don't).

See: <http://creativecommons.org/licenses/by-nd/3.0/>

I say "most", because you also included the "so long as you do not charge
anything for it" phrase in your license. Personally I'm not convinced that
matters much in practice, as who is going to be able to charge for something
you are giving away for free (and if they do, it'll be on a small scale, and
do you really care?), and it's notoriously difficult to define things like
commercial use, but if you feel strongly there's always the Non-Commercial
variant: <http://creativecommons.org/licenses/by-nc-nd/3.0/>

Thanks!

Reference: <http://learnvimscriptthehardway.stevelosh.com/license.html>

~~~
zedshaw
The only time I've ever had someone complain about the "you can't make money"
part of the sentence is when they're trying to run a con. Usually this
involves some scheme to chop up my book and sell it on Amazon or put it up
somewhere else and put ads on it. The problem with this is then the author is
left with mounting support costs for all these copies sold since buyers can't
tell the difference between the copies I wrote and the copies the con artist
sells. They buy it then email me when they get stuck, so I'm left spending my
time making somebody else money.

Anyway, I have a whole rant on how the CC licenses try to do to copyrighted
art what the GPL/BSD does to software and how it just doesn't work the same.

~~~
Flimm
Link to said rant? I'm interested in this, having a group of lawyers write a
common legal text seems like a good thing to me, for both software and art.

------
VeejayRampay
I've been a vim user for something like 6/7 years now and I absolutely love
it, but the editor really shows its age when you realize that its internals
can only be fully customized through vimscript (i.e. you can script it using
Python/Perl/Ruby but none of them offer the same interface and control that
vim's own scripting language, see section 2. on
<http://items.sjbach.com/97/writing-a-vim-plugin>), which is not exactly the
best programming language around.

I wish vim would be rewritten from scratch without changing anything but the
way you access and modify the guts (and possibly the "windowing" system) so
that all the "fancy" plugins like Cmd-T, NerdTree, FuzzyFinder wouldn't look
like crap. The maintainability of said plugins would greatly improve too if
the scripting language was I don't know, Python, Ruby, Javascript/CSS and
whatnot.

------
eliben
I must say, Sublime Text 3 with its Python 3.3 scripting is tempting.
Vimscript is quite horrible.

~~~
pekk
You can script vim with Python.

~~~
eliben
Yes, but AFAIK the API isn't complete there - i.e. not all hooks are exposed
as they are to Vimscript, which explains why with Python "scripting" being
around for a while people still write Vimscript.

~~~
pekk
No, that's FUD. There is nothing wrong with the API exposed to Python. The
main reason to write things in VimL is that this means no dependencies outside
vim, which might be easier on users of your plugin. But a number of major
plugins are written in Python with no problems. It's quite usable.

~~~
eliben
Which dependencies are needed to run Python plugins?

~~~
nudded
Your vim needs to be compiled with python support.

------
gvalkov
Excellent work. Have you considered making this into a Vim reference manual
(:help help-writing [1])? This would make a worthy addition to the Vim
distribution, imho. I always enjoyed reading through the Vim manuals
(especially :help usr_41.txt [2]) on long, unplanned trips.

I'm sorry to say this, but VimL feels like an esoteric language to me. It's
not a _weird_ language per se, but it's certainly a single-purpose language
(Vim's dsl) and there is something depressing in that. I don't find this to be
the case with Emacs and Elisp (a lisp). Historic reasons aside, I think Lua
would have made an excellent scripting language for Vim.

Disclosure: Emacs evil-mode user.

[1]:
[http://code.google.com/p/vim/source/browse/runtime/doc/helph...](http://code.google.com/p/vim/source/browse/runtime/doc/helphelp.txt?name=default#285)

[2]: [http://vim.googlecode.com/hg-
history/default/runtime/doc/usr...](http://vim.googlecode.com/hg-
history/default/runtime/doc/usr_41.txt)

------
burntsushi
This is easily the best material I've seen on Vimscript. Your example plugin
for adapting Vim to a new programming language sealed the deal (especially as
someone who likes to work with new languages). The book is hopefully headed to
the printing press :-)

------
_pmf_
Is it OK to love Vim and hate Vim script? Because I do.

------
darkchasma
This is great, I read the book months ago on github, and have been wanting to
throw some cash at you. I highly recommend it!!!

------
madsravn
Hi Steve,

I love the work you have made with this. I use it as a reference each time I
have to make something new.

Also, I like your idea of two-spacing. :)

------
neduma
I'm gonna try this along with 'Practical Vim'. Thanks.

------
Evbn
Title is a bit redundant. Vimscript is the most stupidly hard (as in, cryptic
syntax and semantics for no good reason) language this side of Brainfuck.

~~~
goldfeld
Not really true. Half of it is just using vim commands within the language
(such as set and normal), and it does get a bit weird with execute and all the
string escaping. Vim regex is quite non-standard but that's because the use
case in the editor makes for very different escaping rules than in
programming, so basically just use very magic more (\v) in code.

The other half is a pretty standard syntax, with exception to needing 'call
function()', which feels like some old language with a strict statement
structure. But the semantics are actually quite similar to JavaScript,
dictionaries especially are very straightforward.

To me the worst part of Vimscript is that it allows every word and command to
be reduced to the minimum unambiguous set of characters, which is
understandable in one-offs in an editing context. But some developers take it
a bit far doing big codebases with those horribly shortened keywords, as much
as it can be done. It just detracts from the community (people who would like
to read code are put off) and quality of open source output.

~~~
johncoltrane
Not being a Pythonista or Rubyist myself (but a PHP/JavaScripter) I found
Vimscript quite easy to get into.

Those things we always hear about Vimscript sucking are mostly cargo culting
by people with no experience with Vimscript in the first place. I personally
hate the syntax of Ruby or Objective-C but I don't go around mocking those
languages.

Anyway, your comment on shortening commands is very true. Case in point, the
great CtrlP plugin:

[https://github.com/kien/ctrlp.vim/blob/master/autoload/ctrlp...](https://github.com/kien/ctrlp.vim/blob/master/autoload/ctrlp.vim#L243)

It's an awful read but, once you replace all the shorthands with full names,
the code is very readable and straightforward. To me, it looks pretty much
like a PHP/JS without braces.

~~~
goldfeld
CtrlP was _exactly_ my mental case in point when I commented on that. I needed
to add some stuff to it, which I did begrudgingly after seeing the source, but
now I'm considering forking it and rewriting in Lua both for speed (it's slow)
and for readability. And as a pet project in Lua, of course.

~~~
johncoltrane
I hear you. Good luck finding users with Vim compiled with lua support,
though.

