Jump to ratings and reviews
Rate this book

Learn Vimscript the Hard Way

Rate this book
Learn Vimscript the Hard Way is a book for users of the Vim editor who want to learn how to customize Vim.

It is not a guide to using Vim. Before reading this book you should be comfortable editing text in Vim and know what terms like "buffer", "window" and "insert mode" mean.

209 pages, ebook

Published April 4, 2013

13 people are currently reading
112 people want to read

About the author

Steve Losh

3 books2 followers

Ratings & Reviews

What do you think?
Rate this book

Friends & Following

Create a free account to discover what your friends think of this book!

Community Reviews

5 stars
34 (39%)
4 stars
42 (48%)
3 stars
10 (11%)
2 stars
1 (1%)
1 star
0 (0%)
Displaying 1 - 18 of 18 reviews
81 reviews9 followers
June 22, 2015
Awesome book to build skills on developing plugins for the Vim text editor.

I've been using Vim for around a decade now, accumulating stolen snippets and tentatively writing some little functions to help me work better sometimes, but after reading this book I feel empowered to do more than that.

You don't even need to read all of it to reap benefits -- heck, you can probably learn a lot just cherry-picking chapters (that's how I started, anyway, until I decided to commit to it and restart from beginning). Most chapters are relatively self-contained, which makes reading cover to cover a little bit repetitive but it's a good thing when using as reference.

Besides teaching the Vimscript basics (and gotchas!), the book guides you through building several kinds of useful customizations (mappings, operators, syntax files, culminating in a full-fledged plugin), giving out lots of vim usage tips along the way. It doesn't try to be comprehensive though (it would be too thick!), it leaves a lot of stuff as exercise and for most non-trivial things you'll still need to consult vim's help or Google/Stackoverflow.

I took my time reading this book: whenever I learned something that seemed to make possible some old idea of mine, I'd stop reading and attempt to implement my idea, and more often than not I'd succeed -- thanks to the newly acquired knowledge.
Just-in-time learning is awesome! =)

I'll probably use Vim for lots of years ahead, maybe even the rest of my life, so I believe all this learning will keep paying dividends. ;)
Recommended for any Vim users that expect to still be using it for the next decade.
Profile Image for Rom.
8 reviews
February 28, 2016
An amazing book on a terrible language. I read it, did most of the exercises, contributed to someone else's plugin and wrote one of my own (different from the one you build in the book).
A few weeks later and after 5 years of using vim full time I switched to emacs.

My favourite highlights from this book were:
* The pointless boilerplate code needed to make vim not do stupid things with your plugin
* Having to use FOUR string comparison operators (==#,==?,!=#,!=?) instead of ==/!= because vimscript
* The horror that is the plugin layout
* The amount of hacks piled onto vimscript throughout the years

After reading this book you'll appreciate two things:
* Tim Pope's work
* Emacs lisp

You really learn a lot from it and if you skip the plugin stuff it is an amazing guide to writing a much much better vimrc. However, if you wanna do something more complex, you spend most of the time fighting with the language and vim's behaviour.

I'd only recommend this to vimmers who are open to changing to Emacs or people who are really into esolangs.
Profile Image for David.
Author 1 book120 followers
February 15, 2020
Excellent! I've read this at least three times in its free online incarnation. I finally purchased the hardback print-on-demand book for reference and to support the author.

2020 Review:
Thanks to this book, I am capable of writing my own Vim plugin. Vimscript actually makes sense in its historical context, but it is so full of pitfalls, a capable guide is invaluable.

I love the approach of this book: it works as a tutorial and as a reference. It's incredibly well structured. If you go through it and do all of the exercises, you WILL be able to write Vimscript and you WILL understand Vim better.

I'm bumping this up to 5/5 stars. I'm not sure why I went with 4/5 previously.


2017 Review:
This book is just what I needed to get over the comprehension hurdle when reading and modifying plugins. I'm a huge fan of the Vimwiki plugin and use it daily, but the "diary" feature needs a couple additional shortcuts to be exactly what I need. I now feel capable of adding them myself.

Vimscript itself is an abomination.
Profile Image for Thomas.
81 reviews6 followers
September 11, 2016
A great introduction to the baroque, deranged and annoyingly useful mess that is scripting and extending Vim. While it doesn't cover all of Vim's dusty corners (which may be beyond all of us aside from Bram Moolenaar and Tim Pope), I certainly picked up a ton of useful concepts/tricks and feel reasonably prepared to dive into others' plugins and start picking apart how they work.

I love technical books that give you real projects and meaningful exercises to do instead of tacking them on as an afterthought, and LVTHW is a great example—you probably won't get much out of this if you don't follow along with them.
Profile Image for Hazel.
93 reviews7 followers
July 15, 2013
Just totally leveled up on my vim/vimscript knowhow.

Enjoyed Steve Losh's writing, except for the constant annoying reminders to *actually do the exercises* -- you can trust me! I actually did them! That was the whole point of me reading this book!
Profile Image for Max Darling.
74 reviews4 followers
March 29, 2023
Before I buckled down to read this book I was pretty efficient editing files in Vim, using motions, substitutions, and macros on a daily basis. But whenever I'd get curious and go lookup something even slightly non-trivial, I'd be presented with this ugly, arcane looking Vimscript. I'd either give up on the spot or haphazardly copy something into my vimrc and not look back. And I know that the vast majority of Vim users are in the same boat. But there's a better way!

Learning Vimscript unlocks true customization. Knowing even a little can get you to a tipping point where the SO answers and help pages start to make sense. My mappings and custom scripts and everything are night and day compared to my old configs. And I finally understand what everything does. And now I'm already writing my own plugins?! I'm having an absolute ball with it. At this rate it'll only be 2-3 more years before I reach feature parity with an IDE! I kid...I kid...that'll never happen obviously ;)
4 reviews
March 18, 2023
This book is a great way to learn Vimscript. After reading it and completing the exercises, I feel confident in writing Vimscript code to customize my Vim experience. My general Vim knowledge was broadened a lot as well. The book was first released a decade ago, but doesn't feel dated in 2023. The exercises are helpful, although no solutions are provided. Be prepared to read a lot of Vim's help pages. The book is available for free on Steve Losh's website. I would highly recommend it.

PS: If you should have trouble installing Potion: before executing `make`, make sure to first clone `https://github.com/libuv/libuv` into `potion/3rd`.
144 reviews5 followers
April 14, 2023
All around, this is a quality book that does a great job of covering Vimscript. Even if you're not planning to write a plugin of your own (the last 3rd of the book), many of the topics covered are extremely practical for the standard Vim user. Furthermore, the author offers the book for free online. I ultimately bought a copy of the eBook for $8 - the least I could do for how helpful the book is.

It would be helpful to have a basic understanding of Vim before delving into the book, and at least one programming language (preferably a scripting language like Bash or Python). But, with those criteria filled, every Vim user should read at least the first two-thirds of this book.
Profile Image for Abhilash.
102 reviews3 followers
February 27, 2017
Very well written and probably only book available on vimscript. Though I read the book cover to cover, I definitely have to re-read it at least a couple of times to get a good understanding of the scripting language.
Profile Image for Tiberiu Georgescu.
2 reviews
June 7, 2020
One of the most in-depth and engaging reads I have had in a long time. Each new chapter is even more demanding than the previous, reaching the point where we write our own plugins!

Highly recommend read for any Vim enthusiast.
9 reviews
September 2, 2020
The book is useful, however I would recommend to buy a hard copy only if you want to support the author. The text is scaled and it has lot of blank pages. It isn’t made for a book format, you can read it in two evenings.
76 reviews13 followers
June 7, 2021
The only one of it's kind! Please do the exercises if you are going through the book. Specialised knowledge is not easy to come by and I highly appreciate the effort the author has put into this epic.

It's the next step after practical vim has drilled itself into your workflow.
Profile Image for Joe Reddington.
Author 3 books5 followers
Read
January 23, 2021
I learned a reasonable amount. I didn't do the exercises, and the book gets progressively more angry about people who don't do the exercises, so really, that caused an increasing level of unease...
421 reviews84 followers
June 14, 2016
"Learn ____ the Hard Way" is a collection of tech books that take a different approach to teaching. Rather than long explanations with little bits of example code, these books just hit you with big chunks of code and ask you to type it in and play with it. Then it explains it, line-by-line. Some of them also have a "how to break it" section, where you actually practice trying to create errors. It's a great idea that gets people more comfortable with making inevitable mistakes and dealing with error messages.

This is such a book, for Vimscript, the configuration language for the Vim text editor. It did not have a "how to break it" section, or much code, or even much explanation. Mostly it was just cursory, flimsy tutorials on various Vimscript features, with long lists of sections in the help file to read on your own. It felt like the author's heart wasn't really in it. If I wanted to read the poorly-written Vim help files, I wouldn't need this book. So, I didn't read any of that crap, and by the end, I wasn't really typing in the code and playing with it anymore. The author didn't seem to care, and I didn't care much either. I did learn some things from this book, but barely enough to make worth reading.
Profile Image for Marcel.
11 reviews7 followers
January 8, 2017
I have sort of a love hate relationship with this book.

I don't like the writing style at all. I hate that the writer, at times, bullies you into doing the exercises or extra reading.
Being a programmer I know the basic building blocks of a programming language. So imo the book starts off rather slow, which surprised me given the title.

After chapter 41 "Creating a Full Plugin" there is a turning point. The potion programming language is introduced and our project is going to be to create a plugin for it. I love that each directory of a plugin is explained and explored. In this part of the book, if you follow along coding, you end up with a complete plugin. It ranges from defining syntax highlighting and custom code folding to autoloading code when it is first needed.

So I now have a vim-potion plugin and have a good understanding of how to create my own. You know what? Goal reached, have another star Steve thanks.
Displaying 1 - 18 of 18 reviews

Can't find what you're looking for?

Get help and learn more about the design.