Learn Vimscript the Hard Way
learnvimscriptthehardway.stevelosh.comPosted Oct 3, 2012, 2:44 PM UTC
Posted Oct 3, 2012, 2:44 PM UTC
Good online book on vim customization with exercises by Steve Losh.
Thank you. I was hoping I'd find a good resource for learning to write vimscript so Il have no excuse to not learn it. This seems like just the thing.
Same for me. This book is just the thing I was looking for. And it popped out out of random google query.
Wow this is awesome! Thanks!
Is there a pdf version of this book?
You can subscribe to some email-thing to get notified once the epubs and pdfs are ready (and for sale)
The source code for the book is available on GitHub in markdown. I tried converting all the markdown into pdf using Pandoc and then merging it - http://ge.tt/9naY0zO/v/0. The result isn't very pretty (no page numbering, headlines etc.), but readable I guess.
One could probably convert the markdown to Latex and get a nice document from it.
That's exactly what Pandoc does. It converts the markdown into LaTeX and then uses pdfLaTeX.
But no page numbers or anything? ;_;
I know the whole "Learn ___ the Hard Way" title reference, but is there actually an easy way available? Vimscript is kind of nasty IMHO.
I'm not sure it's really easier, but if you're looking to try a different tutorial, I just posted links to a five-part series on Vimscript by Damian Conway.
Thank you.
Here's some notes on the very basics of Vimscript's syntax. I think that's at least part of the problem, that its syntax is so different from anything else.
its syntax is so different from anything else
Isn't it different in the same way that Ruby is different from everything else? (In that it's inspired by several different languages, instead of the like-C approach of C++/Java/C#.)
It's probably a lot more confusing if you're trying to program from commandline mode instead of writing a script. Although it just occurred to me that using Ex mode (which I never use) is like a REPL.
While I'm glad this book exists, I don't think I'll be using it. The unfortunate reality is that vimscript is absolutely terrible, and represents a large architectural flaw in an otherwise superb editor.
I'm seriously contemplating switching to emacs evil mode, just to gain access to a reasonable scripting interface.
Are you aware that are other programming languages available to use? The most awesome plugins I use are mostly written in Vimscript. Some of the language features are IMVHO, quite stupid (e.g., the operators), but I don't see how Vimscript is a problem in the Vim world, because I find amazing stuff written in Vimscript. There are also some good Python plugins in my day-to-day features (mainly Ultisnips), but CtrlP, fugitive, surround or Powerline, don't seem to be affected by such a "large architectural flaw".
Are you aware that are other programming languages available to use?
All the scripting languages aside from vimscript are crippled. Looking at Python as an example, you really only have two ways to interact with the Vim runtime: (1) read or modify the buffer and (2) invoke vim.eval() or vim.command() to run snippets of vimscript.
Maybe this is better than vimscript, but not by much.
CtrlP, fugitive, surround or Powerline, don't seem to be affected by such a "large architectural flaw".
The existence of high-quality plugins is not evidence that the implementation language is reasonable (cough PHP cough). Have you ever taken a look at the source code for those projects?
I think emacs lisp is terrible. I guess we are both just going to have to stick to the editors we like.
and I will also use any of the other languages vim supports to script vim, which is not hard, assuming you weren't an emacs partisan to begin with.
The book covers a lot of topics not strictly related to vimscript but usefull for someone already introduced to vim but not on a guru level - leaders, local mappings, autocommands, that kind of things. I, for example, learned about onoremap, never head of that before.
Also along the text there are a lot of tips, snippets that are good to learn from.
The folks who are downvoting you have probably never tried to actually write Vimscript. This book definitely agrees:
I completely agree that vimscript makes php look well designed but I don't think it's a showstopper considering all the great stuff that's written in it. However I still can't imagine writing even a moderately sized project in it. But daily scripting of the editor itself it's more convenient than elisp I would say. Of course I also there was a proper first class language available to script vim. I wonder how much effort it would take to properly integrate lua or some flavour of scheme into vim...
This is my kind of reading material.
Substitute whiskey for those concerned about their weight.